-
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
Engine: Catch NotImplementedError
in get_process_state_change_timestamp
#6489
Engine: Catch NotImplementedError
in get_process_state_change_timestamp
#6489
Conversation
…tamp` The `get_process_state_change_timestamp` utility calls the method `get_global_variable` on the storage backend to get the timestamp of the latest process state change, which is typically stored in the `db_dbsetting` table. However, not all storage plugins implement, most notably the `core.sqlite_zip` plugin. Since this is read-only, the settings table is never used and requesting the timestamp of the last process state change does not make sense. Since this utility is used in `verdi process list`, the command would error since the `NotImplementedError` was not caught. This is now the case and `verdi process list` will show "never" as the last state change.
71d3fd7
to
7966187
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6489 +/- ##
==========================================
+ Coverage 77.51% 77.76% +0.26%
==========================================
Files 560 561 +1
Lines 41444 41800 +356
==========================================
+ Hits 32120 32503 +383
+ Misses 9324 9297 -27 ☔ View full report in Codecov by Sentry. |
try: | ||
timestamp = backend.get_global_variable(key) | ||
except NotImplementedError: | ||
pass | ||
else: | ||
if timestamp is not None: | ||
timestamps.append(datetime.fromisoformat(str(timestamp))) | ||
except KeyError: | ||
continue |
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.
does the same ? :)
try: | |
timestamp = backend.get_global_variable(key) | |
except NotImplementedError: | |
pass | |
else: | |
if timestamp is not None: | |
timestamps.append(datetime.fromisoformat(str(timestamp))) | |
except KeyError: | |
continue | |
timestamp = backend.get_global_variable(key) | |
if timestamp is not None: | |
timestamps.append(datetime.fromisoformat(str(timestamp))) | |
except (KeyError, NotImplementedError) as exc: | |
continue |
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.
Technically yes, however, it is often better to wrap try/except statements around specific lines. This makes it clearer which statements could potentially throw which exception.
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.
makes sense ✅
…tamp` (aiidateam#6489) The `get_process_state_change_timestamp` utility calls the method `get_global_variable` on the storage backend to get the timestamp of the latest process state change, which is typically stored in the `db_dbsetting` table. However, not all storage plugins implement, most notably the `core.sqlite_zip` plugin. Since this is read-only, the settings table is never used and requesting the timestamp of the last process state change does not make sense. Since this utility is used in `verdi process list`, the command would error since the `NotImplementedError` was not caught. This is now the case and `verdi process list` will show "never" as the last state change.
The
get_process_state_change_timestamp
utility calls the methodget_global_variable
on the storage backend to get the timestamp of the latest process state change, which is typically stored in thedb_dbsetting
table. However, not all storage plugins implement, most notably thecore.sqlite_zip
plugin. Since this is read-only, the settings table is never used and requesting the timestamp of the last process state change does not make sense.Since this utility is used in
verdi process list
, the command would error since theNotImplementedError
was not caught. This is now the case andverdi process list
will show "never" as the last state change.