Skip to content

Commit

Permalink
feat(commands): remove use moon forms flag
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-prosser committed Jul 26, 2024
1 parent 5c3a3bb commit 094f7b5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
13 changes: 1 addition & 12 deletions cli/src/commands/create/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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<()> {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -238,7 +229,6 @@ fn upload_annotations_from_reader(
source,
statistics,
dataset_name,
use_moon_forms,
pool,
resume_on_error,
)?;
Expand All @@ -253,7 +243,6 @@ fn upload_annotations_from_reader(
source,
statistics,
dataset_name,
use_moon_forms,
pool,
resume_on_error,
)?;
Expand Down
37 changes: 8 additions & 29 deletions cli/src/commands/create/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -420,7 +401,6 @@ fn upload_comments_from_reader(
source,
statistics,
dataset_name,
use_moon_forms,
pool,
resume_on_error,
)?;
Expand Down Expand Up @@ -448,7 +428,6 @@ fn upload_comments_from_reader(
source,
statistics,
dataset_name,
use_moon_forms,
pool,
resume_on_error,
)?;
Expand Down
6 changes: 2 additions & 4 deletions cli/tests/test_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 094f7b5

Please sign in to comment.