-
Notifications
You must be signed in to change notification settings - Fork 116
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
[develop] Improve error messaging and logging for generate_FV3LAM_wflow.py #414
[develop] Improve error messaging and logging for generate_FV3LAM_wflow.py #414
Conversation
@mkavulich The unittest is failing probably due to a mixup of the community and nco test cases settings. I recall that when i first called |
ceb4c4d
to
b00f98d
Compare
@danielabdi-noaa I restored the multiprocessing to the unit tests in generate_FV3LAM_wflow.py, but I am still seeing errors that I don't understand (I can't figure out how to see the full logs). I am on PTO Monday and Tuesday but I may ask for a quick meeting after that to try to figure out what I did wrong. |
@mkavulich You can run the unittest locally
It looks like you are just missing a
|
By the way, is it possible to override how the logger prints messages so that it automatically dedents them just like |
@danielabdi-noaa Thanks for the info, the tests seem to be working now!
There's no built-in way to do this as far as I can tell, but I could add a new function that does this. I didn't want to change the existing |
@mkavulich Are you thinking of modifying the logger.info/debug behaviour to include dedentation automatically or a separate function? As you pointed out, there is no built-in way but there seem to be workarounds like this that will automatically dedent both console and logfile output. I tried it quickly on your PR with this patch, and it looks like it does the job. |
@danielabdi-noaa We could discuss a better strategy in the future but I don't want to "force" dedenting on all log messages, so I have implemented it as a separate function similar to Thanks for all your comments here so far, I am opening this up for wider review but let me know if you have additional comments/suggestions. |
Machine: hera |
Machine: jet |
- Remove/consolidate outdated or unnecessary comments - Remove print of rocoto details; it is now impossible for users to get this far *without* having loaded a module that includes rocoto - Add logging to get_crontab_contents.py
Bug in check_var_valid_value.py caused an unrelated exception if the intended check failed and err_msg was not specified. Turns out that nowhere in the code is err_msg used, so let's get rid of it! In addition, trying to check an empty string caused an *additional* exception, so added some logic to handle that case.
necessary for CI testing
…why this didn't fail in manual tests...
function with built-in dedenting.
This reverts commit 252f91d.
…um requirement); reverting to older format
5d43ec2
to
73a5c50
Compare
@christinaholtNOAA I believe I have addressed most of your concerns and followed up on the rest with a few comments/questions. Let me know what you think. |
Machine: jet |
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.
Everything looks good to me. The last two items (a comment below and an unresolved previous comment) are purely cosmetic.
Machine: hera |
@danielabdi-noaa I think you still have one un-resolved comment as well, let me know if everything looks good! |
I've now run almost all error testing cases listed in the PR description and they work as expected so approving. Only the following case looks like it is impossible to catch on Hera atleast. If we run a WE2E test case though without conda activation, it would have been probably caught!
This one is disabled to get unittests working and i think for now it should be that way in my opinion. I've had to disable a couple of hard exits to get unittests working before, but if the benefits outweight the cons we could get rid of the unittests.
|
@danielabdi-noaa Agreed on both counts. It would be nice to implement a check that the code is built, but I agree we will need to think of a better way to sync that with automated tests. |
This PR is now open for review
DESCRIPTION OF CHANGES:
The error messaging in the generate_FV3LAM_wflow.py has been overhauled to be more pythonic and more user-friendly. The old bash-like
print_err_msg_exit()
calls are replaced with proper exception handling, andprint_info_msg()
calls are replaced with the use of Python's built-in logging module. The latter has the added benefit of giving the same "tee"-like functionality--where messages are printed to screen and written to a log file simultaneously--without the need for messy subprocesses and the confusing error messages that come with them.Errors are now handled in a consistent way, with the errors clearly highlighted both on screen and in the log file, as well as an easy-to-follow exception traceback for those wanting that information. In addition, several error conditions that were previously not caught at the generate step now cause the script to fail with helpful error messages.
From the user perspective, functionality will not change, aside from differences when error conditions are present. Successful runs will remain the same, except that some log messaging has been clarified, and the log file contains additional information for each message, as well as some indentation changes for ease of reading.
Example output
In this example, I specified an invalid variable "INVALID_VAR" in config.yaml. In the current code, the script succeeds, which is a dangerous condition that can produce unexpected results:
Updated code:
For this same case, the log file shows the following text:
In the log file you can see the above-mentioned additional information. Before each message, the subroutine writing the message is listed (a few top-level processes involving setting up logging and printing the error message are logged as "root"). Next on the line is a note of the "logging level"; see Logging HOWTO for more details, but basically this denotes the "urgency" of the message, with "debug" being the lowest and "error" being the highest used here, indicating the script has failed in some way. While not implemented here, this will allow us to properly quarantine lower-priority printouts to the log file, or only print them to screen if DEBUG=TRUE, by making use of lower-priority levels such as logging.debug. And finally, log messages that extend to multiple lines are indented by two spaces, to make individual messages easier to parse visually.
Type of change
TESTS CONDUCTED:
MACHINE
ACCOUNT
withWORKFLOW_MANAGER=rocoto
DEPENDENCIES:
None
DOCUMENTATION:
None, though the new, clearer error messaging and removal of extraneous comments could be considered a type of documentation change.
Check the comments on #385 for more examples of the differences in error messages.
ISSUE:
Fixes #385
CHECKLIST
CONTRIBUTORS (optional):