Conversation
In DRAGONS astrodata, exceptions are just passed. This makes certain frequent debugging issues painful, because relevant exceptions are obscured and therefore the source of a (real) problem is lost. This update keeps the errors around, and reports them if no matching astrodata object is found. This was originally logged, but that choice doesn't coincide with DRAGON's logging principles (and it was also too high of an error level, in any case). This solution captures exceptions and reports them (as part of the error message, with stack traces) if the matching process fails. If there are no exceptions, or the process succeeds, behavior is still preserved as it was.
Same as with get_astro_data, but for opening the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In DRAGONS, exceptions caught during certain critical
AstroDataFactorymethods, like._open_fileand.get_astro_datawere discarded. This caused problems with testing, debugging, and maintenance ofastrodata. It also makes development (with or of)astrodatamore difficult when working on file handlers orAstroDataobjects.The previous (quick) solution to this was to log the exceptions. However, DRAGONS expects that logs are clean in instances where there are no issues with creating an
AstroDataobject from a file/from data. The log level for that message was also too high (error).This PR decreases the logging level for these messages (debug), and intead catched errors. Caught exceptions are only reported if the data fails to match at all and there were exceptions raised while matching was occuring. This preserves the expected behavior while providing a more informative exception message.
Notes
This only works if no registered
AstroData<Name>class object successfully matches, or none of the file openers inAstroDataFactory._file_openerssuccessfully open the file. E.g., it still will not report exceptions if any objects/file openers are "successful", even if unintentional or unexpected.To remedy that while preserving previous behavior, messages are still logged at the "debug" level to aid in debugging problems with
AstroDataFactory.