-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add bot comments in app.cfg.example #170
Conversation
@@ -134,3 +134,24 @@ poll_interval = 60 | |||
|
|||
# full path to the command for manipulating existing jobs | |||
scontrol_command = /usr/bin/scontrol | |||
|
|||
|
|||
[submitted_job_comments] |
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.
add a comment above here to indicate that some of these comments should not be changed because we have regular expression patterns in the code that match them
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.
Looks already quite good. Basic functionality is there.
The PR needs to be updated with the head of the EESSI/eessi-bot-software-layer repository (some conflicts for tasks/build.py
).
Wonder a bit if variable names could be made more telling (more than comments
) and settings could get unique names (a few are named comment
... they are in different sections, but might be confusing still).
When accessing configuration settings and sections we tried to use constants, typically defined at the beginning of a file, e.g.,
eessi-bot-software-layer/tasks/build.py
Line 26 in feb7493
BUILDENV = "buildenv" |
and in the code then use these, e.g.,
eessi-bot-software-layer/tasks/build.py
Line 78 in feb7493
buildenv = cfg[BUILDENV] |
Benefit of that is that we avoid problems caused by typos and could change the names more easily at a single place (where constants are defined).
Now that we use settings from app.cfg
there is a risk that some setting is not defined. Should we add some function that provides a limited check that certain configuration settings are available? Similarly to what is done in EESSI/filesystem-layer#90 with defining required config settings (file scripts/automated_ingestion/automated_ingestion.py
lines 17-22) and using them (same file, lines 64-69). At the start the job manager and the event handler could check that the configuration contains the required settings and stops if not.
tasks/build.py
Outdated
job_comment = (f"New job on instance `{app_name}`" | ||
f" for architecture `{arch_name}`" | ||
f" in job dir `{symlink}`\n" | ||
comments = config.read_config()["submitted_job_comments"] |
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.
Wonder a bit if comments
is a good name for the variable. It's more like submit_comment_cfg
???
eessi_bot_job_manager.py
Outdated
@@ -291,9 +291,10 @@ def process_new_job(self, new_job): | |||
# (c) add a row to the table | |||
# add row to status table if we found a comment | |||
if "comment_id" in new_job: | |||
comments = config.read_config()["new_job_comments"] |
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.
Wonder a bit if comments
is a good name for the variable. It's more like new_job_comment_cfg
or put it into the job_manager section [job_manager]
???
eessi_bot_job_manager.py
Outdated
update = "\n|%s|" % dt.strftime("%b %d %X %Z %Y") | ||
update += "released|job awaits launch by Slurm scheduler|" | ||
update = "\n|%s|released|" % dt.strftime("%b %d %X %Z %Y") | ||
update += f"{comments['comment']}|" |
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.
comments['comment']
is very generic. Could we come up with names describing their purpose better?
E.g., job_mgr_cfg['new_job_comment']
or job_manager['new_job_comment']
eessi_bot_job_manager.py
Outdated
comments = config.read_config()["running_job_comments"] | ||
running_msg = comments['comment'].format(job_id=running_job['jobid']) |
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.
See comment about naming variables and configuration settings. Here, something like
job_manager_cfg = config.read_config()["job_manager"]
running_msg = job_manager_cfg["running_job_comment"].format...
Might make the code a bit more readable.
update = "\n|%s|" % dt.strftime("%b %d %X %Z %Y") | ||
update += "running|" + running_msg | ||
update = f"\n|{dt.strftime('%b %d %X %Z %Y')}|running|" | ||
update += f"{running_msg}|" |
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.
Nice that you added the missing |
!
eessi_bot_job_manager.py
Outdated
@@ -463,20 +465,17 @@ def process_finished_job(self, finished_job): | |||
|
|||
dt = datetime.now(timezone.utc) | |||
|
|||
comments = config.read_config()["finished_job_comments"] |
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.
See other comments about variable naming.
@@ -463,20 +465,17 @@ def process_finished_job(self, finished_job): | |||
|
|||
dt = datetime.now(timezone.utc) | |||
|
|||
comments = config.read_config()["finished_job_comments"] | |||
comment_update = f"\n|{dt.strftime('%b %d %X %Z %Y')}|finished|" |
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.
Good that you have rearranged the code!
app.cfg.example
Outdated
comment = job id `{job_id}` awaits release by job manager | ||
|
||
[new_job_comments] | ||
comment = job awaits launch by Slurm scheduler | ||
|
||
[running_job_comments] | ||
comment = job `{job_id}` is running |
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 setting comment
is used multiple times. It might be a bit confusing. Could we come up with unique names?
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.
Thanks for the update. A few minor things could be changed. But could be done in a follow up PR. I'll run a test and if it works, I'll just merge it (even without the suggested changes).
@@ -43,6 +43,27 @@ | |||
|
|||
from pyghee.utils import log, error | |||
|
|||
AWAITS_LAUCH = "awaits_lauch" |
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.
Small typo. Should probably be AWAITS_LAUNCH = "awaits_launch"
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.
See #173
@@ -138,3 +138,24 @@ poll_interval = 60 | |||
|
|||
# full path to the command for manipulating existing jobs | |||
scontrol_command = /usr/bin/scontrol | |||
|
|||
# variable 'comment' under 'submitted_job_comments' should not be changed as there are regular expression patterns matching it |
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.
Suggest a small modification to use the new variable name initial_comment
and mentioning "code", e.g., "... should not be changed as the bot's code uses regular expression pattern to identify a matching comment"
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.
See #173
awaits_release = job id `{job_id}` awaits release by job manager | ||
|
||
[new_job_comments] | ||
awaits_lauch = job awaits launch by Slurm scheduler |
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.
Small typo. Should be awaits_launch
.
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.
@trz42 Hmm, this typo was not resolved? 🤔
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.
See #173
SUCCESS = "success" | ||
|
||
REQUIRED_CONFIG = { | ||
NEW_JOB_COMMENTS: [AWAITS_LAUCH], |
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.
Small typo. Should be AWAITS_LAUNCH
.
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.
See #173
update = "\n|%s|" % dt.strftime("%b %d %X %Z %Y") | ||
update += "released|job awaits launch by Slurm scheduler|" | ||
update = "\n|%s|released|" % dt.strftime("%b %d %X %Z %Y") | ||
update += f"{new_job_comments_cfg[AWAITS_LAUCH]}|" |
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.
Small typo. Should be AWAITS_LAUNCH
.
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.
See #173
REQUIRED_CONFIG = { | ||
NEW_JOB_COMMENTS: [AWAITS_LAUCH], | ||
RUNNING_JOB_COMMENTS: [RUNNING_JOB], | ||
FINISHED_JOB_COMMENTS: [SUCCESS, FAILURE, NO_SLURM_OUT, SLURM_OUT, MISSING_MODULES, |
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.
Do we really need to make this required in the bot configuration file?
Why don't we just fall back to a default comment if the bot isn't configured with a custom comment?
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.
Created #176
No description provided.