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): add lossy flag when creating annotations #289

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

joe-prosser
Copy link
Contributor

Adding a flag to attempt to resume processing when operations fail. Starting with annotations but could later be used for comments also

@joe-prosser joe-prosser requested a review from dan-ri July 24, 2024 13:09
@joe-prosser joe-prosser self-assigned this Jul 24, 2024

#[structopt(long)]
/// Whether to attempt to resume processing on error
lossy: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

lossy isn't very descriptive. How about resume-on-error?

Comment on lines 379 to 388
format!(
"{} {}{}",
num_annotations,
"annotations".dimmed(),
if num_failed_annotations > 0 {
format!(" {} {}", num_failed_annotations, "skipped".dimmed())
} else {
"".to_string()
}
),
Copy link
Contributor

Choose a reason for hiding this comment

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

The nested format! is a bit cheeky. How about:

let failed_annotations_string = if num_failed_annotations > 0 {
    format!(" {num_failed_annotations} {}", "skipped".dimmed())
} else {
    String::new()
};

Similarly below.

cli/src/main.rs Outdated
Comment on lines 206 to 218
pub fn print_error_as_warning(error: &anyhow::Error) {
warn!("An error occurred. Resuming...");
for cause in error.chain() {
warn!(" |- {}", cause);
}
}

pub fn print_error(error: &anyhow::Error) {
error!("An error occurred:");
for cause in error.chain() {
error!(" |- {}", cause);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need two functions. How about just

pub fn print_error(error: &anyhow::Error) {
    for cause in error.chain() {
        error!(" |- {}", cause);
    }
}

and leave the call to error!()before it in main() below. You can add the call to warn!() in upload_batch_of_annotations(), but I'm not sure logging in that case is necessary.

@joe-prosser joe-prosser requested a review from dan-ri July 24, 2024 14:31
@joe-prosser joe-prosser merged commit b90a6b6 into master Jul 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants