-
Notifications
You must be signed in to change notification settings - Fork 192
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
CLI: Only configure logging in set_log_level
callback once
#6493
Merged
sphuber
merged 1 commit into
aiidateam:main
from
sphuber:fix/verdi-logging-configuration
Jun 28, 2024
Merged
CLI: Only configure logging in set_log_level
callback once
#6493
sphuber
merged 1 commit into
aiidateam:main
from
sphuber:fix/verdi-logging-configuration
Jun 28, 2024
Conversation
This file contains 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
All `verdi` commands automatically have the `-v/--verbosity` option added. This option has a callback `set_log_level` that is invoked for each subcommand. The callback is supposed to call `configure_logging` to setup the logging configuration. Besides it being unnecessary to call it multiple times for each subcommand, it would actually cause a bug in that once the profile storage would have been loaded (through the callback of the profile option), which would have called `configure_logging` with `with_orm=True` to make sure the `DbLogHandler` was properly configured, another call to `set_log_level` would call `configure_logging` with the default values (where `with_orm=False`) and so the `DbLogHandler` would be removed. This would result in process log messages not being persisted in the database. This would be manifested when running an AiiDA process through a script invoked through `verdi` or any other CLI that uses the verbosity option provided by `aiida-core`. Since the `set_log_level` only has to make sure that the logging is configured at least once, a guard is added to skip the configuration once the `aiida.common.log.CLI_ACTIVE` global has been set by a previous invocation.
sphuber
force-pushed
the
fix/verdi-logging-configuration
branch
from
June 28, 2024 14:25
fc9383d
to
10e2de5
Compare
GeigerJ2
approved these changes
Jun 28, 2024
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.
In @sphuber we trust 🙏🏽
mikibonacci
pushed a commit
to mikibonacci/aiida-core
that referenced
this pull request
Sep 3, 2024
…am#6493) All `verdi` commands automatically have the `-v/--verbosity` option added. This option has a callback `set_log_level` that is invoked for each subcommand. The callback is supposed to call `configure_logging` to setup the logging configuration. Besides it being unnecessary to call it multiple times for each subcommand, it would actually cause a bug in that once the profile storage would have been loaded (through the callback of the profile option), which would have called `configure_logging` with `with_orm=True` to make sure the `DbLogHandler` was properly configured, another call to `set_log_level` would call `configure_logging` with the default values (where `with_orm=False`) and so the `DbLogHandler` would be removed. This would result in process log messages not being persisted in the database. This would be manifested when running an AiiDA process through a script invoked through `verdi` or any other CLI that uses the verbosity option provided by `aiida-core`. Since the `set_log_level` only has to make sure that the logging is configured at least once, a guard is added to skip the configuration once the `aiida.common.log.CLI_ACTIVE` global has been set by a previous invocation.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6493 +/- ##
==========================================
+ Coverage 77.51% 77.77% +0.26%
==========================================
Files 560 561 +1
Lines 41444 41801 +357
==========================================
+ Hits 32120 32505 +385
+ Misses 9324 9296 -28 ☔ View full report in Codecov by Sentry. |
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.
All
verdi
commands automatically have the-v/--verbosity
option added. This option has a callbackset_log_level
that is invoked for each subcommand. The callback is supposed to callconfigure_logging
to setup the logging configuration.Besides it being unnecessary to call it multiple times for each subcommand, it would actually cause a bug in that once the profile storage would have been loaded (through the callback of the profile option), which would have called
configure_logging
withwith_orm=True
to make sure theDbLogHandler
was properly configured, another call toset_log_level
would callconfigure_logging
with the default values (wherewith_orm=False
) and so theDbLogHandler
would be removed. This would result in process log messages not being persisted in the database. This would be manifested when running an AiiDA process through a script invoked throughverdi
or any other CLI that uses the verbosity option provided byaiida-core
.Since the
set_log_level
only has to make sure that the logging is configured at least once, a guard is added to skip the configuration once theaiida.common.log.CLI_ACTIVE
global has been set by a previous invocation.