From 094f7b5811bc09fc0b61dc17faf011669a19cd7b Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Fri, 26 Jul 2024 14:06:21 +0100 Subject: [PATCH] feat(commands): remove use moon forms flag --- CHANGELOG.md | 1 + cli/src/commands/create/annotations.rs | 13 +-------- cli/src/commands/create/comments.rs | 37 ++++++-------------------- cli/tests/test_comments.rs | 6 ++--- 4 files changed, 12 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e0a066..2bf1557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Add ability to download attachments for comments - Increase default http timeout to 120s - Add `--resume-on-error` flag when creating annotations +- Remove `--use-moon-forms` flag # v0.28.0 - Add general fields to `create datasets` diff --git a/cli/src/commands/create/annotations.rs b/cli/src/commands/create/annotations.rs index 285dbb2..4eb9b02 100644 --- a/cli/src/commands/create/annotations.rs +++ b/cli/src/commands/create/annotations.rs @@ -39,11 +39,6 @@ pub struct CreateAnnotationsArgs { /// Don't display a progress bar (only applicable when --file is used). no_progress: bool, - #[structopt(long)] - /// Whether to use the moon_forms field when creating annotations - /// for a comment. - use_moon_forms: bool, - #[structopt(long = "batch-size", default_value = "128")] /// Number of comments to batch in a single request. batch_size: usize, @@ -96,7 +91,6 @@ pub fn create(client: &Client, args: &CreateAnnotationsArgs, pool: &mut Pool) -> file, &statistics, &dataset_name, - args.use_moon_forms, args.batch_size, pool, args.resume_on_error, @@ -119,7 +113,6 @@ pub fn create(client: &Client, args: &CreateAnnotationsArgs, pool: &mut Pool) -> BufReader::new(io::stdin()), &statistics, &dataset_name, - args.use_moon_forms, args.batch_size, pool, args.resume_on_error, @@ -147,7 +140,6 @@ pub fn upload_batch_of_annotations( source: &Source, statistics: &(impl AnnotationStatistic + std::marker::Sync), dataset_name: &DatasetFullName, - use_moon_forms: bool, pool: &mut Pool, resume_on_error: bool, ) -> Result<()> { @@ -161,7 +153,7 @@ pub fn upload_batch_of_annotations( let comment_uid = CommentUid(format!("{}.{}", source.id.0, new_comment.comment.id.0)); - let result = (if !use_moon_forms { + let result = (if new_comment.moon_forms.is_none() { client.update_labelling( dataset_name, &comment_uid, @@ -219,7 +211,6 @@ fn upload_annotations_from_reader( annotations: impl BufRead, statistics: &Statistics, dataset_name: &DatasetFullName, - use_moon_forms: bool, batch_size: usize, pool: &mut Pool, resume_on_error: bool, @@ -238,7 +229,6 @@ fn upload_annotations_from_reader( source, statistics, dataset_name, - use_moon_forms, pool, resume_on_error, )?; @@ -253,7 +243,6 @@ fn upload_annotations_from_reader( source, statistics, dataset_name, - use_moon_forms, pool, resume_on_error, )?; diff --git a/cli/src/commands/create/comments.rs b/cli/src/commands/create/comments.rs index e18a7c3..2a09c96 100644 --- a/cli/src/commands/create/comments.rs +++ b/cli/src/commands/create/comments.rs @@ -62,11 +62,6 @@ pub struct CreateCommentsArgs { /// which is already associated to different data on the platform. overwrite: bool, - #[structopt(long)] - /// Whether to use the moon_forms field when creating annotations - /// for a comment. - use_moon_forms: bool, - #[structopt(short = "n", long = "no-charge")] /// Whether to attempt to bypass billing (internal only) no_charge: bool, @@ -153,7 +148,6 @@ pub fn create(client: &Client, args: &CreateCommentsArgs, pool: &mut Pool) -> Re dataset_name.as_ref(), args.overwrite, args.allow_duplicates, - args.use_moon_forms, args.no_charge, pool, args.resume_on_error, @@ -182,7 +176,6 @@ pub fn create(client: &Client, args: &CreateCommentsArgs, pool: &mut Pool) -> Re dataset_name.as_ref(), args.overwrite, args.allow_duplicates, - args.use_moon_forms, args.no_charge, pool, args.resume_on_error, @@ -333,7 +326,6 @@ fn upload_comments_from_reader( dataset_name: Option<&DatasetFullName>, overwrite: bool, allow_duplicates: bool, - use_moon_forms: bool, no_charge: bool, pool: &mut Pool, resume_on_error: bool, @@ -359,25 +351,14 @@ fn upload_comments_from_reader( let new_comment = read_comment_result?; if dataset_name.is_some() && new_comment.has_annotations() { - if !use_moon_forms { - annotations.push(NewAnnotation { - comment: CommentIdComment { - id: new_comment.comment.id.clone(), - }, - labelling: new_comment.labelling.map(Into::into), - entities: new_comment.entities, - moon_forms: None, - }); - } else { - annotations.push(NewAnnotation { - comment: CommentIdComment { - id: new_comment.comment.id.clone(), - }, - labelling: None, - entities: None, - moon_forms: new_comment.moon_forms.map(Into::into), - }); - }; + annotations.push(NewAnnotation { + comment: CommentIdComment { + id: new_comment.comment.id.clone(), + }, + labelling: new_comment.labelling, + entities: new_comment.entities, + moon_forms: new_comment.moon_forms.map(Into::into), + }); } if let Some(audio_path) = new_comment.audio_path { @@ -420,7 +401,6 @@ fn upload_comments_from_reader( source, statistics, dataset_name, - use_moon_forms, pool, resume_on_error, )?; @@ -448,7 +428,6 @@ fn upload_comments_from_reader( source, statistics, dataset_name, - use_moon_forms, pool, resume_on_error, )?; diff --git a/cli/tests/test_comments.rs b/cli/tests/test_comments.rs index a2c2a40..ed5195b 100644 --- a/cli/tests/test_comments.rs +++ b/cli/tests/test_comments.rs @@ -29,10 +29,7 @@ fn test_comments_lifecycle_moon_forms() { // check without moon forms check_comments_lifecycle(SAMPLE_MOON_LABELLING, vec!["--allow-duplicates", "--yes"]); // and with moon forms - check_comments_lifecycle( - SAMPLE_MOON_LABELLING, - vec!["--allow-duplicates", "--yes", "--use-moon-forms"], - ); + check_comments_lifecycle(SAMPLE_MOON_LABELLING, vec!["--allow-duplicates", "--yes"]); } #[test] @@ -177,6 +174,7 @@ fn test_delete_comments_in_range() { dataset1.identifier(), source.identifier(), ]); + assert_eq!(uploaded_annotated.lines().count(), num_annotated); // Delete comments in range. By default this should exclude annotated comments