Skip to content

Commit

Permalink
Merge pull request EESSI#277 from smoors/det_submit_opts
Browse files Browse the repository at this point in the history
add support for updating Slurm options
  • Loading branch information
trz42 authored Sep 6, 2024
2 parents 5a950dc + fb72c7b commit d17c46a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ no_build_permission_comment = The `bot: build ...` command has been used by user
`no_build_permission_comment` defines a comment (template) that is used when
the account trying to trigger build jobs has no permission to do so.

```
allow_update_submit_opts = false
```
`allow_update_submit_opts` determines whether or not to allow updating the submit
options via custom module `det_submit_opts` provided by the pull request being
processed.


#### `[bot_control]` section

Expand Down
4 changes: 4 additions & 0 deletions app.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# author: Jonas Qvigstad (@jonas-lq)
# author: Pedro Santos Neves (@Neves-P)
# author: Thomas Roeblitz (@trz42)
# author: Sam Moors (@smoors)
#
# license: GPLv2
#
Expand Down Expand Up @@ -128,6 +129,9 @@ build_permission =
# template for comment when user who set a label has no permission to trigger build jobs
no_build_permission_comment = Label `bot:build` has been set by user `{build_labeler}`, but this person does not have permission to trigger builds

# whether or not to allow updating the submit options via custom module det_submit_opts
allow_update_submit_opts = false


[deploycfg]
# script for uploading built software packages
Expand Down
2 changes: 2 additions & 0 deletions eessi_bot_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# author: Lara Ramona Peeters (@laraPPr)
# author: Thomas Roeblitz (@trz42)
# author: Pedro Santos Neves (@Neves-P)
# author: Sam Moors (@smoors)
#
# license: GPLv2
#
Expand Down Expand Up @@ -47,6 +48,7 @@
config.BOT_CONTROL_SETTING_COMMAND_PERMISSION, # required
config.BOT_CONTROL_SETTING_COMMAND_RESPONSE_FMT], # required
config.SECTION_BUILDENV: [
# config.BUILDENV_SETTING_ALLOW_UPDATE_SUBMIT_OPTS # optional
config.BUILDENV_SETTING_BUILD_JOB_SCRIPT, # required
config.BUILDENV_SETTING_BUILD_LOGS_DIR, # optional+recommended
config.BUILDENV_SETTING_BUILD_PERMISSION, # optional+recommended
Expand Down
19 changes: 19 additions & 0 deletions tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# author: Lara Ramona Peeters (@laraPPr)
# author: Pedro Santos Neves (@Neves-P)
# author: Thomas Roeblitz (@trz42)
# author: Sam Moors (@smoors)
#
# license: GPLv2
#
Expand Down Expand Up @@ -658,6 +659,24 @@ def submit_job(job, cfg):
else:
time_limit = f"--time={DEFAULT_JOB_TIME_LIMIT}"

# update job.slurm_opts with det_submit_opts(job) in det_submit_opts.py if allowed and available
do_update_slurm_opts = False
allow_update_slurm_opts = cfg[config.SECTION_BUILDENV].getboolean(config.BUILDENV_SETTING_ALLOW_UPDATE_SUBMIT_OPTS)

if allow_update_slurm_opts:
sys.path.append(job.working_dir)

try:
from det_submit_opts import det_submit_opts # pylint:disable=import-outside-toplevel
do_update_slurm_opts = True
except ImportError:
log(f"{fn}(): not updating job.slurm_opts: "
"cannot import function det_submit_opts from module det_submit_opts")

if do_update_slurm_opts:
job = job._replace(slurm_opts=det_submit_opts(job))
log(f"{fn}(): updated job.slurm_opts: {job.slurm_opts}")

command_line = ' '.join([
build_env_cfg[config.BUILDENV_SETTING_SUBMIT_COMMAND],
build_env_cfg[config.BUILDENV_SETTING_SLURM_PARAMS],
Expand Down
2 changes: 2 additions & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# author: Jacob Ziemke (@jacobz137)
# author: Jonas Qvigstad (@jonas-lq)
# author: Thomas Roeblitz (@trz42)
# author: Sam Moors (@smoors)
#
# license: GPLv2
#
Expand All @@ -36,6 +37,7 @@
BOT_CONTROL_SETTING_COMMAND_RESPONSE_FMT = 'command_response_fmt'

SECTION_BUILDENV = 'buildenv'
BUILDENV_SETTING_ALLOW_UPDATE_SUBMIT_OPTS = 'allow_update_submit_opts'
BUILDENV_SETTING_BUILD_JOB_SCRIPT = 'build_job_script'
BUILDENV_SETTING_BUILD_LOGS_DIR = 'build_logs_dir'
BUILDENV_SETTING_BUILD_PERMISSION = 'build_permission'
Expand Down

0 comments on commit d17c46a

Please sign in to comment.