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(abt): speed up analyses battery with async analysis #16431

Merged
merged 9 commits into from
Oct 8, 2024

Conversation

y3rsh
Copy link
Member

@y3rsh y3rsh commented Oct 8, 2024

Overview

Remove cruft from generate_analyses.py and analyze against n containers in a ThreadPoolExecutor.

  • Works locally
  • Works in CI

@y3rsh y3rsh requested a review from a team as a code owner October 8, 2024 15:02
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

TY! Here's a Python coding practices suggestion, but it doesn't block merging.

Comment on lines +222 to +223
except Exception as e:
console.print(f"An error occurred during analysis: {e}")
Copy link
Contributor

@SyntaxColoring SyntaxColoring Oct 8, 2024

Choose a reason for hiding this comment

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

For future reference, as a general practice, I think we should avoid stringifying exceptions like {e} or str(e). It can be okay for certain exception types, but in the general except Exception case, like here, it can give you confusing and incomplete information. For example, if a KeyError came from some_dict["foo"], this would only print:

An error occurred during analysis: foo

If you're using logging, you can do exc_info=True to automatically include full exception information, like:

except Exception:
    log.warn("An error occurred during analysis.", exc_info=True)

If you're not using logging, like in this case, you can use something like traceback.print_exception() (output to a file) or traceback.format_exception() (output to a string).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. Helped me in another spot today 😊
I will merge this but will fix this to use Rich console exception printing in another PR. It is totally wrong.

@y3rsh y3rsh merged commit 6869198 into edge Oct 8, 2024
6 checks passed
@y3rsh y3rsh deleted the abt-async-analyses branch October 8, 2024 19:09
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