Skip to content

Commit bcf7279

Browse files
committed
make modules actually optional
skip also default modules.yaml when config:modules:false
1 parent 963d948 commit bcf7279

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

stackinator/builder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ def generate(self, recipe):
463463
with (generate_config_path / "Makefile").open("w") as f:
464464
f.write(
465465
make_config_template.render(
466+
modules=recipe.config["modules"],
466467
build_path=self.path.as_posix(),
467468
all_compilers=all_compilers,
468469
release_compilers=all_compilers,
@@ -471,11 +472,12 @@ def generate(self, recipe):
471472
)
472473

473474
# write modules/modules.yaml
474-
modules_yaml = recipe.modules_yaml
475-
generate_modules_path = self.path / "modules"
476-
generate_modules_path.mkdir(exist_ok=True)
477-
with (generate_modules_path / "modules.yaml").open("w") as f:
478-
f.write(modules_yaml)
475+
if recipe.config["modules"]:
476+
modules_yaml = recipe.modules_yaml
477+
generate_modules_path = self.path / "modules"
478+
generate_modules_path.mkdir(exist_ok=True)
479+
with (generate_modules_path / "modules.yaml").open("w") as f:
480+
f.write(modules_yaml)
479481

480482
# write the meta data
481483
meta_path = store_path / "meta"

stackinator/recipe.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def __init__(self, args):
6363
self.generate_compiler_specs(raw)
6464

6565
# optional modules.yaml file
66-
modules_path = self.path / "modules.yaml"
67-
self._logger.debug(f"opening {modules_path}")
68-
if not modules_path.is_file():
69-
modules_path = pathlib.Path(args.build) / "spack/etc/spack/defaults/base/modules.yaml"
70-
self._logger.debug(f"no modules.yaml provided - using the {modules_path}")
71-
72-
self.modules = modules_path
66+
if self.config["modules"]:
67+
modules_path = self.path / "modules.yaml"
68+
self._logger.debug(f"opening {modules_path}")
69+
if not modules_path.is_file():
70+
modules_path = pathlib.Path(args.build) / "spack/etc/spack/defaults/base/modules.yaml"
71+
self._logger.debug(f"no modules.yaml provided - using the {modules_path}")
72+
self.modules = modules_path
7373

7474
# optional packages.yaml file
7575
packages_path = self.path / "packages.yaml"
@@ -314,7 +314,10 @@ def environment_view_meta(self):
314314
return view_meta
315315

316316
@property
317-
def modules_yaml(self):
317+
def modules_yaml(self) -> str:
318+
if not self.config["modules"]:
319+
raise RuntimeError("modules are not enabled in config.yaml")
320+
318321
with self.modules.open() as fid:
319322
raw = yaml.load(fid, Loader=yaml.Loader)
320323
raw["modules"]["default"]["roots"]["tcl"] = (pathlib.Path(self.mount) / "modules").as_posix()

stackinator/templates/Makefile.generate-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ALL_COMPILER_PREFIXES ={% for compiler in all_compilers %} $$($(SPACK_HELPER) -e
1010
COMPILER_PREFIXES ={% for compiler in release_compilers %} $$($(SPACK_HELPER) -e ../compilers/{{ compiler }} find --explicit --format='{prefix}' gcc llvm llvm-amdgpu nvhpc){% endfor %}
1111

1212

13-
all: $(CONFIG_DIR)/upstreams.yaml $(CONFIG_DIR)/packages.yaml $(CONFIG_DIR)/repos.yaml $(MODULE_DIR)/upstreams.yaml $(MODULE_DIR)/compilers.yaml
13+
all: $(CONFIG_DIR)/upstreams.yaml $(CONFIG_DIR)/packages.yaml $(CONFIG_DIR)/repos.yaml{% if modules %} $(MODULE_DIR)/upstreams.yaml $(MODULE_DIR)/compilers.yaml{% endif %}
1414

1515
# Generate the upstream configuration that will be provided by the mounted image
1616
$(CONFIG_DIR)/upstreams.yaml:

0 commit comments

Comments
 (0)