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

Improve Python Exception Readability/Consistency #281

Closed
TimothyWillard opened this issue Aug 5, 2024 · 4 comments
Closed

Improve Python Exception Readability/Consistency #281

TimothyWillard opened this issue Aug 5, 2024 · 4 comments
Assignees
Labels
gempyor Concerns the Python core. good first issue Good for newcomers. medium priority Medium priority.

Comments

@TimothyWillard
Copy link
Contributor

We should strive to make exceptions readable and consistent throughout gempyor. Some general style guidelines include:

  1. Choosing the correct exception for the given issue instead of just defaulting to ValueError or Exception,
  2. Making exceptions 1-2 short sentences with no new lines/awkward spacing,
  3. Provide context for debugging, something like "expected 'x' to have 5 elements but instead has 7.".

I'm certain there are more guidelines we could come up with though. In some rare cases we might also want to create custom exceptions, one such exceptions I could see an argument for already is FlepimopConfigError or similar for configuration related issues. However, we should evaluate if that's really needed before implementing.

A good first step would be surveying gempyor for wherever we raise something just to get an idea of where we're starting from. I expect that resolving this issue will take more than one PR and will probably be included as a part of other PRs along the way.

Original context for this issue: https://github.com/HopkinsIDD/flepiMoP/pull/277/files#r1702272495.

@TimothyWillard TimothyWillard added good first issue Good for newcomers. gempyor Concerns the Python core. medium priority Medium priority. labels Aug 5, 2024
@emprzy
Copy link
Collaborator

emprzy commented Aug 16, 2024

Creating a checklist of Python files within gempyor_pkg/src/gempyor as I comb through and check for improvable instances of exceptions/errors (just for my own organization):

  • __init__.py
  • calibrate.py
  • cli.py
  • compartments.py NEEDS ATTENTION
  • config_validator.py NEEDS ATTENTION
  • file_paths.py
  • inference.py NEEDS ATTENTION
  • inference_parameter.py
  • initial_conditions.py NEEDS ATTENTION
  • logloss.py
  • model_info.py NEEDS ATTENTION
  • outcomes.py NEEDS ATTENTION
  • parameters.py NEEDS ATTENTION
  • postprocess_inference.py
  • profile_old.py
  • seeding.py NEEDS ATTENTION
  • seir.py NEEDS ATTENTION
  • simulate.py
  • simulation_component.py
  • statistics.py NEEDS ATTENTION
  • steps_rk4.py
  • steps_source.py
  • subpopulation_structure.py NEEDS ATTENTION
  • testing.py
  • utils.py NEEDS ATTENTION

@emprzy emprzy self-assigned this Aug 16, 2024
@Juhi-Lakdawala
Copy link

Hello emprzy,
I was looking for some good first issue and came across this one. I would also like to help with this issue. I would like to help with exception handling mechanism. Can you assign me this issue

@emprzy
Copy link
Collaborator

emprzy commented Sep 4, 2024

Hi @Juhi-Lakdawala ! flepiMoP issues are typically for flepiMoP contributors only, sorry!

emprzy added a commit to emprzy/flepiMoP that referenced this issue Sep 16, 2024
…les.

Adjusted formatting, punctuation, clarity, syntax, etc. in the errors/exceptions in `gempyor`'s initial_conditions.py, parameters.py, compartments.py, config_validator.py, inference.py. This will likely be one of three pulls to address HopkinsIDDGH-281.
@TimothyWillard TimothyWillard added this to the Software Quality milestone Dec 6, 2024
@TimothyWillard
Copy link
Contributor Author

Resolved by GH-313 & GH-387.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gempyor Concerns the Python core. good first issue Good for newcomers. medium priority Medium priority.
Projects
None yet
Development

No branches or pull requests

3 participants