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

feat(commands): remove use moon forms flag #293

Merged
merged 3 commits into from
Jul 26, 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
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
15 changes: 2 additions & 13 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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still only uploads entities without moon forms, we need to pass the entities in the else clause as well

client.update_labelling(
dataset_name,
&comment_uid,
Expand All @@ -178,7 +170,7 @@ pub fn upload_batch_of_annotations(
dataset_name,
&comment_uid,
None,
None,
new_comment.entities.as_ref(),
new_comment.moon_forms.as_deref(),
)
})
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: 1 addition & 5 deletions cli/tests/test_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ fn test_comments_lifecycle_moon_forms() {
const SAMPLE_MOON_LABELLING: &str = include_str!("./samples/moon_forms.jsonl");
// 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"],
);
}

#[test]
Expand Down Expand Up @@ -177,6 +172,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
Loading