Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(labelling): Fix label prediction type #258

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# unreleased
- Fix a bug where some label annotations cannot be applied

# v0.22.1
- minor api improvements

Expand Down
9 changes: 8 additions & 1 deletion api/src/resources/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,16 @@ pub struct Label {
pub metadata: Option<HashMap<String, JsonValue>>,
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum PredictedLabelName {
Parts(Vec<String>),
String(LabelName),
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct PredictedLabel {
pub name: Vec<String>,
pub name: PredictedLabelName,
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment: Option<NotNan<f64>>,
pub probability: NotNan<f64>,
Expand Down
8 changes: 5 additions & 3 deletions cli/src/commands/get/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use regex::Regex;
use reinfer_client::{
resources::{
comment::{
CommentTimestampFilter, MessagesFilter, PropertyFilterKind, ReviewedFilterEnum,
UserPropertiesFilter,
CommentTimestampFilter, MessagesFilter, PredictedLabelName, PropertyFilterKind,
ReviewedFilterEnum, UserPropertiesFilter,
},
dataset::{
Attribute, AttributeFilter, AttributeFilterEnum, OrderEnum, QueryRequestParams,
Expand Down Expand Up @@ -613,7 +613,9 @@ fn get_comments_from_uids(
auto_threshold_labels
.iter()
.map(|auto_threshold_label| PredictedLabel {
name: auto_threshold_label.name.to_owned(),
name: PredictedLabelName::String(LabelName(
auto_threshold_label.name.join(" > "),
)),
sentiment: None,
probability: auto_threshold_label.probability,
auto_thresholds: Some(
Expand Down
Loading