-
Notifications
You must be signed in to change notification settings - Fork 20
Modify Config during Error Checking #1341
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
base: release
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |
| import sys | ||
| import time | ||
|
|
||
| import dpath.util | ||
| import psutil | ||
|
|
||
| from loguru import logger | ||
|
|
||
| from . import database_actions, helpers, logfiles | ||
|
|
@@ -143,12 +143,35 @@ def assemble_error_list(config): | |
| frequency = int(frequency) | ||
| except: | ||
| frequency = 60 | ||
| if ( | ||
|
||
| "set_config_key" in config[model]["check_error"][trigger] | ||
| and "set_config_value" in config[model]["check_error"][trigger] | ||
| ): | ||
| set_config_key = config[model]["check_error"][trigger][ | ||
| "set_config_key" | ||
| ] | ||
| set_config_value = config[model]["check_error"][trigger][ | ||
| "set_config_value" | ||
| ] | ||
| else: | ||
| set_config_key = None | ||
| set_config_value = None | ||
|
|
||
| elif isinstance(config[model]["check_error"][trigger], str): | ||
| pass | ||
| else: | ||
| continue | ||
| error_list.append( | ||
| (trigger, search_file, method, frequency, frequency, message) | ||
| ( | ||
| trigger, | ||
| search_file, | ||
| method, | ||
| frequency, | ||
| frequency, | ||
| message, | ||
| set_config_key, | ||
| set_config_value, | ||
| ) | ||
| ) | ||
| config["general"]["error_list"] = error_list | ||
| return config | ||
|
|
@@ -171,6 +194,8 @@ def check_for_errors(config): | |
| next_check, | ||
| frequency, | ||
| message, | ||
| set_config_key, | ||
| set_config_value, | ||
| ) in error_check_list: | ||
| warned = 0 | ||
| if next_check <= time: | ||
|
|
@@ -181,8 +206,31 @@ def check_for_errors(config): | |
| if method == "warn": | ||
| warned = 1 | ||
| monitor_file.write("WARNING: " + message + "\n") | ||
| if ( | ||
| set_config_key is not None | ||
| and set_config_value is not None | ||
| ): | ||
| dpath.util.set( | ||
| config, | ||
| set_config_key, | ||
| set_config_value, | ||
| separator=".", | ||
| ) | ||
| logger.info( | ||
| f"Set {set_config_key}={set_config_value} in check_for_errors" | ||
| ) | ||
| break | ||
| elif method == "kill": | ||
| if ( | ||
| set_config_key is not None | ||
| and set_config_value is not None | ||
| ): | ||
| dpath.util.set( | ||
| config, | ||
| set_config_key, | ||
| set_config_value, | ||
| separator=".", | ||
| ) | ||
| cancel_job = f"scancel {config['general']['jobid']}" | ||
| monitor_file.write("ERROR: " + message + "\n") | ||
| monitor_file.write("Will kill the run now..." + "\n") | ||
|
|
@@ -195,7 +243,16 @@ def check_for_errors(config): | |
| next_check += frequency | ||
| if warned == 0: | ||
| new_list.append( | ||
| (trigger, search_file, method, next_check, frequency, message) | ||
| ( | ||
| trigger, | ||
| search_file, | ||
| method, | ||
| next_check, | ||
| frequency, | ||
| message, | ||
| set_config_key, | ||
| set_config_value, | ||
| ) | ||
| ) | ||
| config["general"]["error_list"] = new_list | ||
| return config | ||
|
|
||
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.
The version specifier '>=2.0.7' contradicts the comment stating a maximum version is required for Python 3.6 support. Consider revising the version constraint (e.g., using '<=' if a maximum version is intended).
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.
This is a bad suggestion, or maybe an indication of bad working in my comment: we need 2.0.7 or newer (2.0.7 is the highest version still supports Python 3.6)