From 7213f563d7334c8041e98d15f6af5e3bedd4dc17 Mon Sep 17 00:00:00 2001 From: bcumming Date: Tue, 10 Mar 2026 17:19:58 +0100 Subject: [PATCH 1/2] add support for default-view in config.yaml --- stackinator/builder.py | 1 + stackinator/recipe.py | 24 ++++++++++++++++-------- stackinator/schema/config.json | 25 +++++++------------------ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/stackinator/builder.py b/stackinator/builder.py index 2c05e3c1..ae4997a1 100644 --- a/stackinator/builder.py +++ b/stackinator/builder.py @@ -156,6 +156,7 @@ def environment_meta(self, recipe): meta["name"] = conf["name"] meta["description"] = conf["description"] meta["views"] = recipe.environment_view_meta + meta["default-view"] = recipe.default_view meta["mount"] = str(recipe.mount) modules = None if recipe.with_modules: diff --git a/stackinator/recipe.py b/stackinator/recipe.py index ca8d2b3d..180293f7 100644 --- a/stackinator/recipe.py +++ b/stackinator/recipe.py @@ -87,14 +87,6 @@ def __init__(self, args): self._logger.error(f"modules.yaml:{self.with_modules}") raise RuntimeError("conflicting modules configuration detected") - # optional packages.yaml file - packages_path = self.path / "packages.yaml" - self._logger.debug(f"opening {packages_path}") - self.packages = None - if packages_path.is_file(): - with packages_path.open() as fid: - self.packages = yaml.load(fid, Loader=yaml.Loader) - self._logger.debug("creating packages") # load recipe/packages.yaml -> recipe_packages (if it exists) @@ -169,6 +161,15 @@ def __init__(self, args): schema.EnvironmentsValidator.validate(raw) self.generate_environment_specs(raw) + # check that the default view exists (if one has been set) + self._default_view = self.config["default-view"] + if self._default_view is not None: + if self._default_view not in [view["name"] for env in self.environments.values() for view in env["views"]]: + self._logger.warning( + "The default-view {self.default_view} is not the name of a view in the environments.yaml definition" + ) + raise RuntimeError("Ivalid default-view in the recipe.") + # optional mirror configurtion mirrors_path = self.path / "mirrors.yaml" if mirrors_path.is_file(): @@ -286,6 +287,13 @@ def with_modules(self) -> bool: def find_spack_version(self, develop): return "1.0" + # Returns: + # Path: if the recipe contains a spack package repository + # None: if there is the recipe contains no repo + @property + def default_view(self): + return self._default_view + @property def environment_view_meta(self): # generate the view meta data that is presented in the squashfs image meta data diff --git a/stackinator/schema/config.json b/stackinator/schema/config.json index d6fec3a0..d9de503e 100644 --- a/stackinator/schema/config.json +++ b/stackinator/schema/config.json @@ -46,24 +46,6 @@ } } }, - "mirror" : { - "type" : "object", - "additionalProperties": false, - "default": {"enable": true, "key": null}, - "properties" : { - "enable" : { - "type": "boolean", - "default": true - }, - "key" : { - "oneOf": [ - {"type" : "string"}, - {"type" : "null"} - ], - "default": null - } - } - }, "modules" : { "type": "boolean" }, @@ -74,6 +56,13 @@ ], "default": null }, + "default-view" : { + "oneOf": [ + {"type" : "string"}, + {"type" : "null"} + ], + "default": null + }, "version" : { "type": "number", "default": 1, From 38dc2943a9979284a887e1fd86c905a4dbb6eb0d Mon Sep 17 00:00:00 2001 From: bcumming Date: Wed, 11 Mar 2026 13:03:57 +0100 Subject: [PATCH 2/2] support setting modules and spack views as default view --- stackinator/recipe.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stackinator/recipe.py b/stackinator/recipe.py index 180293f7..fe5d9e72 100644 --- a/stackinator/recipe.py +++ b/stackinator/recipe.py @@ -164,9 +164,15 @@ def __init__(self, args): # check that the default view exists (if one has been set) self._default_view = self.config["default-view"] if self._default_view is not None: - if self._default_view not in [view["name"] for env in self.environments.values() for view in env["views"]]: - self._logger.warning( - "The default-view {self.default_view} is not the name of a view in the environments.yaml definition" + available_views = [view["name"] for env in self.environments.values() for view in env["views"]] + # add the modules and spack views to the list of available views + if self.with_modules: + available_views.append("modules") + available_views.append("spack") + if self._default_view not in available_views: + self._logger.error( + f"The default-view {self._default_view} is not the name of a view in the environments.yaml " + "definition (one of {[name for name in available_views]}" ) raise RuntimeError("Ivalid default-view in the recipe.")