From cd1fa4b157951da426a47f7ea7f3270335aa9cc7 Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Wed, 31 Jan 2024 14:08:46 +0000 Subject: [PATCH 1/2] fix(labelling): Fixed label prediction type --- CHANGELOG.md | 3 +++ api/src/resources/comment.rs | 8 +++++++- cli/src/commands/get/comments.rs | 8 +++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbcf8cf..66f21de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# unreleased +- Fix a bug where some label annotations cannot be applied + # v0.22.1 - minor api improvements diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index b6fc138..22aff79 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -624,9 +624,15 @@ pub struct Label { pub metadata: Option>, } +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +pub enum PredictedLabelName { + Parts(Vec), + String(LabelName), +} + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct PredictedLabel { - pub name: Vec, + pub name: PredictedLabelName, #[serde(skip_serializing_if = "Option::is_none")] pub sentiment: Option>, pub probability: NotNan, diff --git a/cli/src/commands/get/comments.rs b/cli/src/commands/get/comments.rs index 02f7b8e..66b6f60 100644 --- a/cli/src/commands/get/comments.rs +++ b/cli/src/commands/get/comments.rs @@ -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, @@ -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( From 4d147b13f469dfe379ab8c4c9fccc95d014d45ba Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Wed, 31 Jan 2024 14:25:13 +0000 Subject: [PATCH 2/2] actually fix it this time --- api/src/resources/comment.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index 22aff79..0bf3209 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -625,6 +625,7 @@ pub struct Label { } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[serde(untagged)] pub enum PredictedLabelName { Parts(Vec), String(LabelName),