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

Runner: module force purge and module use #255

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions caput/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,7 @@ def from_yaml_str(cls, yaml_doc, lint=False, psutil_profiling=False):
try:
if not isinstance(yaml_params["pipeline"], dict):
raise config.CaputConfigError(
"Value 'pipeline' in YAML configuration is of type '{}' (expected a YAML block here).".format(
type(yaml_params["pipeline"]).__name__
),
f"Value 'pipeline' in YAML configuration is of type '{type(yaml_params['pipeline']).__name__}' (expected a YAML block here).",
location=yaml_params,
)
except TypeError as e:
Expand Down
29 changes: 21 additions & 8 deletions caput/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,16 @@ def queue(
*processors* on a node.
``venv``
Path to a virtual environment to load before running.
``modules``
``module_list``
Only used for slurm.
A list of modules environments to load before running a job.
If set, a module purge will occur before loading the specified modules.
Sticky modules like StdEnv/* on Cedar will not get purged, and
should not be specified.
If not set, the current environment is used.
``module_path``
Only used for slurm.
A list of modules paths to use. May be required to load modules.
``temp_directory``
If set, save the output to a temporary location while running and
then move to a final location if the job successfully finishes. This
Expand Down Expand Up @@ -484,13 +487,23 @@ def queue(
if sfile != dfile:
shutil.copyfile(sfile, dfile)

if rconf.get("modules"):
modules = rconf["modules"]
modules = (modules,) if isinstance(modules, str) else modules
modstr = "module purge\nmodule load "
modstr += "\nmodule load ".join(modules)
else:
modstr = ""
# Get any modules that should be loaded
modlist = rconf.get("module_list")
modpath = rconf.get("module_path")
modstr = ""

if modpath:
if isinstance(modpath, str):
modpath = (modpath,)
modstr += "module use " + "\nmodule use ".join(modpath)

if modlist:
if isinstance(modlist, str):
modlist = (modlist,)
modstr += "\nmodule load " + "\nmodule load ".join(modlist)

if modstr:
modstr = "module --force purge\n" + modstr

rconf["modules"] = modstr

Expand Down
Loading