Skip to content

Commit

Permalink
don't use default module name
Browse files Browse the repository at this point in the history
  • Loading branch information
smoors committed Oct 19, 2024
1 parent 86d2cbb commit 50be479
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,16 @@ 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 python module provided by the pull request
being processed.
`allow_update_submit_opts` determines whether or not to allow updating the
submit options via custom python module provided by the pull request being
processed. Enabling this also requires `update_submit_opts_modname` to be set.

```
update_submit_opts_modname = MODULE_NAME
```
Replace `MODULE_NAME` with the name of custom python module used to determine
updated submit options (default is `det_submit_opts`)
Replace `MODULE_NAME` with the name of a python module, located in the root dir
of the target repo, and containing function `det_submit_options()`, which will
be used to determine updated submit options.

#### `[bot_control]` section

Expand Down
2 changes: 1 addition & 1 deletion app.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ no_build_permission_comment = Label `bot:build` has been set by user `{build_lab
# whether or not to allow updating the submit options via custom python module det_submit_opts
allow_update_submit_opts = false

# name of custom python module used to determine updated submit options (default: det_submit_opts)
# name of custom python module used to determine updated submit options
det_submit_opts_modname = det_submit_opts

[deploycfg]
Expand Down
18 changes: 11 additions & 7 deletions tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,21 +692,25 @@ 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
# update job.slurm_opts with det_submit_opts(job) in custom python module 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)
det_submit_opts_modname = cfg[config.SECTION_BUILDENV].get(config.BUILDENV_SETTING_DET_SUBMIT_OPTS_MODNAME)
det_submit_opts = importlib.import_module(det_submit_opts_modname)

try:
from det_submit_opts import det_submit_opts # pylint:disable=import-outside-toplevel
do_update_slurm_opts = True
except ImportError:
if not det_submit_opts_modname:
log(f"{fn}(): not updating job.slurm_opts: "
"cannot import function det_submit_opts from module det_submit_opts")
"config setting {config.BUILDENV_SETTING_DET_SUBMIT_OPTS_MODNAME} not set")
else:
try:
det_submit_opts = importlib.import_module(det_submit_opts_modname)
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_modname}")

if do_update_slurm_opts:
job = job._replace(slurm_opts=det_submit_opts(job))
Expand Down

0 comments on commit 50be479

Please sign in to comment.