From 99f42b1daab8170e80c5f6e370f03ce7c8fcab4a Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 1 Sep 2024 12:53:36 +0200 Subject: [PATCH 1/3] add support for updating submit options --- tasks/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tasks/build.py b/tasks/build.py index 059b30c..39c4778 100644 --- a/tasks/build.py +++ b/tasks/build.py @@ -658,6 +658,20 @@ 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 available + do_update_slurm_opts = False + 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], From 4517ab225231283653ffa97360bda0c4fba13719 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 3 Sep 2024 20:45:59 +0200 Subject: [PATCH 2/3] make it configurable --- app.cfg.example | 3 +++ eessi_bot_event_handler.py | 1 + tasks/build.py | 18 +++++++++++------- tools/config.py | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app.cfg.example b/app.cfg.example index a5a0964..b65ada6 100644 --- a/app.cfg.example +++ b/app.cfg.example @@ -128,6 +128,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 diff --git a/eessi_bot_event_handler.py b/eessi_bot_event_handler.py index 91274fb..a94e078 100644 --- a/eessi_bot_event_handler.py +++ b/eessi_bot_event_handler.py @@ -47,6 +47,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 diff --git a/tasks/build.py b/tasks/build.py index 39c4778..903800b 100644 --- a/tasks/build.py +++ b/tasks/build.py @@ -658,15 +658,19 @@ 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 available + # update job.slurm_opts with det_submit_opts(job) in det_submit_opts.py if allowed and available do_update_slurm_opts = False - sys.path.append(job.working_dir) + allow_update_slurm_opts = cfg[config.SECTION_BUILDENV].getboolean(config.BUILDENV_SETTING_ALLOW_UPDATE_SUBMIT_OPTS) - 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 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)) diff --git a/tools/config.py b/tools/config.py index f1deb34..6675fd8 100644 --- a/tools/config.py +++ b/tools/config.py @@ -36,6 +36,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' From 62a493329e43d47d5b1a9078aa94fb9bd2628b2b Mon Sep 17 00:00:00 2001 From: Thomas Roeblitz Date: Fri, 6 Sep 2024 11:51:17 +0200 Subject: [PATCH 3/3] updating authors in changed files and add setting to README.md --- README.md | 7 +++++++ app.cfg.example | 1 + eessi_bot_event_handler.py | 1 + tasks/build.py | 1 + tools/config.py | 1 + 5 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 2eb0de7..8af58a9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app.cfg.example b/app.cfg.example index b65ada6..25abf91 100644 --- a/app.cfg.example +++ b/app.cfg.example @@ -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 # diff --git a/eessi_bot_event_handler.py b/eessi_bot_event_handler.py index a94e078..ac943fa 100644 --- a/eessi_bot_event_handler.py +++ b/eessi_bot_event_handler.py @@ -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 # diff --git a/tasks/build.py b/tasks/build.py index 903800b..a967ef7 100644 --- a/tasks/build.py +++ b/tasks/build.py @@ -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 # diff --git a/tools/config.py b/tools/config.py index 6675fd8..da8a287 100644 --- a/tools/config.py +++ b/tools/config.py @@ -10,6 +10,7 @@ # author: Jacob Ziemke (@jacobz137) # author: Jonas Qvigstad (@jonas-lq) # author: Thomas Roeblitz (@trz42) +# author: Sam Moors (@smoors) # # license: GPLv2 #