-
Notifications
You must be signed in to change notification settings - Fork 43
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
filename_parser() no longer raises an exception for unrecognized files #1614
filename_parser() no longer raises an exception for unrecognized files #1614
Conversation
Hello @bhilbert4, Thank you for updating ! Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated at 2024-08-20 18:17:34 UTC |
@mfixstsci @york-stsci I've cleaned up the changes here to make them a little more consistent amongst the various calls to filename_parser(). Tests are all passing, so I think this is ready for review. I'll take care of the PEP8 stuff momentarily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of redundant comments, but my basic point is that we should probably choose a specific way of getting output from the file parser, testing that output for validity, and reacting to it. I don't mind if we're doing try/except or if/then, but we should probably pick one and use it.
My second note is that we need to make sure that, when the parser fails, we log that failure in a way that's connected not only to the specific monitor that's running, but to the specific place within that monitor where the failure happened.
The combination of the above suggests to me that, annoying as it is, wrapping the call to filename_parser()
in a try/except block, and logging the exception (along with what stage of the monitor it is, what file it was trying to parse, and how it got that file (i.e. from user input for a search, from a self-generated list, from some other source) is probably the cleanest way to make sure we have the necessary context.
Ok @york-stsci, have a look. I updated the files to add logging statements in the calling functions. I kept the logging statement in filename_parser() itself. Maybe with testing we can see if that statement makes it into the expected log. Running locally, I can try a few of these cases tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bhilbert4 assuming that you've addressed all of @york-stsci comments I am cool with merging this in.
Adjust the filename_parser() such that when it is called on a filename it doesn't recognize, it no longer raises an exception, but instead returns a dictionary with a key indicating that the filename wasn't recognized.