Skip to content

Commit 25d09fb

Browse files
committed
add support for customizing EasyBuild command used in jobs via --job-eb-cmd
1 parent 4c3b052 commit 25d09fb

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

easybuild/tools/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
DEFAULT_ENVVAR_USERS_MODULES = 'HOME'
9090
DEFAULT_INDEX_MAX_AGE = 7 * 24 * 60 * 60 # 1 week (in seconds)
9191
DEFAULT_JOB_BACKEND = 'GC3Pie'
92+
DEFAULT_JOB_EB_CMD = 'eb'
9293
DEFAULT_LOGFILE_FORMAT = ("easybuild", "easybuild-%(name)s-%(version)s-%(date)s.%(time)s.log")
9394
DEFAULT_MAX_FAIL_RATIO_PERMS = 0.5
9495
DEFAULT_MINIMAL_BUILD_ENV = 'CC:gcc,CXX:g++'
@@ -328,6 +329,9 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
328329
DEFAULT_INDEX_MAX_AGE: [
329330
'index_max_age',
330331
],
332+
DEFAULT_JOB_EB_CMD: [
333+
'job_eb_cmd',
334+
],
331335
DEFAULT_MAX_FAIL_RATIO_PERMS: [
332336
'max_fail_ratio_adjust_permissions',
333337
],

easybuild/tools/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
from easybuild.tools.build_log import init_logging, log_start, print_msg, print_warning, raise_easybuilderror
6262
from easybuild.tools.config import CONT_IMAGE_FORMATS, CONT_TYPES, DEFAULT_CONT_TYPE, DEFAULT_ALLOW_LOADED_MODULES
6363
from easybuild.tools.config import DEFAULT_BRANCH, DEFAULT_ENV_FOR_SHEBANG, DEFAULT_ENVVAR_USERS_MODULES
64-
from easybuild.tools.config import DEFAULT_FORCE_DOWNLOAD, DEFAULT_INDEX_MAX_AGE
64+
from easybuild.tools.config import DEFAULT_FORCE_DOWNLOAD, DEFAULT_INDEX_MAX_AGE, DEFAULT_JOB_EB_CMD
6565
from easybuild.tools.config import DEFAULT_JOB_BACKEND, DEFAULT_LOGFILE_FORMAT, DEFAULT_MAX_FAIL_RATIO_PERMS
6666
from easybuild.tools.config import DEFAULT_MINIMAL_BUILD_ENV, DEFAULT_MNS, DEFAULT_MODULE_SYNTAX, DEFAULT_MODULES_TOOL
6767
from easybuild.tools.config import DEFAULT_MODULECLASSES, DEFAULT_PATH_SUBDIRS, DEFAULT_PKG_RELEASE, DEFAULT_PKG_TOOL
@@ -798,6 +798,7 @@ def job_options(self):
798798
'cores': ("Number of cores to request per job", 'int', 'store', None),
799799
'deps-type': ("Type of dependency to set between jobs (default depends on job backend)",
800800
'choice', 'store', None, [JOB_DEPS_TYPE_ABORT_ON_ERROR, JOB_DEPS_TYPE_ALWAYS_RUN]),
801+
'eb-cmd': ("EasyBuild command to use in jobs", 'str', 'store', DEFAULT_JOB_EB_CMD),
801802
'max-jobs': ("Maximum number of concurrent jobs (queued and running, 0 = unlimited)", 'int', 'store', 0),
802803
'max-walltime': ("Maximum walltime for jobs (in hours)", 'int', 'store', 24),
803804
'output-dir': ("Output directory for jobs (default: current directory)", None, 'store', os.getcwd()),

easybuild/tools/parallelbuild.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,14 @@ def submit_jobs(ordered_ecs, cmd_line_opts, testing=False, prepare_first=True):
141141
# compose string with command line options, properly quoted and with '%' characters escaped
142142
opts_str = ' '.join(opts).replace('%', '%%')
143143

144-
command = "unset TMPDIR && cd %s && eb %%(spec)s %s %%(add_opts)s --testoutput=%%(output_dir)s" % (curdir, opts_str)
145-
_log.info("Command template for jobs: %s" % command)
144+
eb_cmd = build_option('job_eb_cmd')
145+
146+
command = ' && '.join([
147+
"unset TMPDIR",
148+
"cd %s" % curdir,
149+
"%s %%(spec)s %s %%(add_opts)s --testoutput=%%(output_dir)s" % (eb_cmd, opts_str),
150+
])
151+
_log.info("Command template for jobs: %s", command)
146152
if testing:
147153
_log.debug("Skipping actual submission of jobs since testing mode is enabled")
148154
return command

test/framework/parallelbuild.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from easybuild.framework.easyconfig.tools import process_easyconfig
3838
from easybuild.tools import config
3939
from easybuild.tools.build_log import EasyBuildError
40-
from easybuild.tools.config import get_module_syntax
40+
from easybuild.tools.config import get_module_syntax, update_build_option
4141
from easybuild.tools.filetools import adjust_permissions, mkdir, read_file, remove_dir, which, write_file
4242
from easybuild.tools.job import pbs_python
4343
from easybuild.tools.job.pbs_python import PbsPython
@@ -322,6 +322,12 @@ def test_submit_jobs(self):
322322
regex = re.compile(regex)
323323
self.assertFalse(regex.search(cmd), "Pattern '%s' should *not* be found in: %s" % (regex.pattern, cmd))
324324

325+
# test again with custom EasyBuild command to use in jobs
326+
update_build_option('job_eb_cmd', "/just/testing/bin/eb --debug")
327+
cmd = submit_jobs([toy_ec], eb_go.generate_cmd_line(), testing=True)
328+
regex = re.compile(r" && /just/testing/bin/eb --debug %\(spec\)s ")
329+
self.assertTrue(regex.search(cmd), "Pattern '%s' found in: %s" % (regex.pattern, cmd))
330+
325331
def test_build_easyconfigs_in_parallel_slurm(self):
326332
"""Test build_easyconfigs_in_parallel(), using (mocked) Slurm as backend for --job."""
327333

0 commit comments

Comments
 (0)