Skip to content
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

Merged
merged 11 commits into from
Apr 6, 2023
Merged

Add bot comments in app.cfg.example #170

merged 11 commits into from
Apr 6, 2023

Conversation

jonas-lq
Copy link
Collaborator

No description provided.

@boegel boegel requested a review from trz42 March 28, 2023 07:09
boegel
boegel previously requested changes Mar 28, 2023
@@ -134,3 +134,24 @@ poll_interval = 60

# full path to the command for manipulating existing jobs
scontrol_command = /usr/bin/scontrol


[submitted_job_comments]
Copy link
Contributor

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

Copy link
Contributor

@trz42 trz42 left a 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.,

BUILDENV = "buildenv"

and in the code then use these, e.g.,
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"]
Copy link
Contributor

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 ???

@@ -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"]
Copy link
Contributor

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] ???

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']}|"
Copy link
Contributor

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']

Comment on lines 367 to 368
comments = config.read_config()["running_job_comments"]
running_msg = comments['comment'].format(job_id=running_job['jobid'])
Copy link
Contributor

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}|"
Copy link
Contributor

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 | !

@@ -463,20 +465,17 @@ def process_finished_job(self, finished_job):

dt = datetime.now(timezone.utc)

comments = config.read_config()["finished_job_comments"]
Copy link
Contributor

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|"
Copy link
Contributor

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 on lines 141 to 147
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
Copy link
Contributor

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?

@jonas-lq jonas-lq marked this pull request as draft March 29, 2023 07:28
@jonas-lq jonas-lq marked this pull request as ready for review March 31, 2023 15:22
Copy link
Contributor

@trz42 trz42 left a 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"
Copy link
Contributor

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"

Copy link
Contributor

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
Copy link
Contributor

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"

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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? 🤔

Copy link
Contributor

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],
Copy link
Contributor

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.

Copy link
Contributor

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]}|"
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #173

@trz42 trz42 merged commit 6241d41 into EESSI:main Apr 6, 2023
REQUIRED_CONFIG = {
NEW_JOB_COMMENTS: [AWAITS_LAUCH],
RUNNING_JOB_COMMENTS: [RUNNING_JOB],
FINISHED_JOB_COMMENTS: [SUCCESS, FAILURE, NO_SLURM_OUT, SLURM_OUT, MISSING_MODULES,
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #176

jonas-lq added a commit to jonas-lq/eessi-bot-software-layer that referenced this pull request Apr 11, 2023
@jonas-lq jonas-lq deleted the issue#109 branch April 28, 2023 10:54
@boegel boegel added this to the 0.1.0 - initial release milestone Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants