diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2024-11-02 09:03:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-02 09:03:42 +0100 |
commit | 133895e7852a03ffeac473d16949c92df90e65ee (patch) | |
tree | ff539c9934aaead829ccd0f2b971f4d31d72d33b /lib | |
parent | 19e3ab83cfee8fdbd2c19e23c1b93ef83e92fbc4 (diff) | |
download | spack-133895e7852a03ffeac473d16949c92df90e65ee.tar.gz spack-133895e7852a03ffeac473d16949c92df90e65ee.tar.bz2 spack-133895e7852a03ffeac473d16949c92df90e65ee.tar.xz spack-133895e7852a03ffeac473d16949c92df90e65ee.zip |
Rework the schema for reusing environments (#47364)
Currently, the schema reads:
from:
- type:
environment: path_or_name
but this can't be extended easily to other types, e.g. to buildcaches,
without duplicating the extension keys. Use instead:
from:
- type: environment
path: path_or_name
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/schema/concretizer.py | 25 | ||||
-rw-r--r-- | lib/spack/spack/solver/asp.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 6 |
3 files changed, 13 insertions, 22 deletions
diff --git a/lib/spack/spack/schema/concretizer.py b/lib/spack/spack/schema/concretizer.py index b52b305ed9..86e58de258 100644 --- a/lib/spack/spack/schema/concretizer.py +++ b/lib/spack/spack/schema/concretizer.py @@ -32,24 +32,15 @@ properties: Dict[str, Any] = { "type": "object", "properties": { "type": { - "oneOf": [ - { - "type": "string", - "enum": [ - "local", - "buildcache", - "environment", - "external", - ], - }, - { - "type": "object", - "properties": { - "environment": {"type": "string"} - }, - }, - ] + "type": "string", + "enum": [ + "local", + "buildcache", + "external", + "environment", + ], }, + "path": {"type": "string"}, "include": LIST_OF_SPECS, "exclude": LIST_OF_SPECS, }, diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index af2b8a70c3..ba50ebccd0 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -4103,8 +4103,8 @@ class ReusableSpecsSelector: for source in reuse_yaml.get("from", default_sources): include = source.get("include", default_include) exclude = source.get("exclude", default_exclude) - if isinstance(source["type"], dict): - env_dir = ev.as_env_dir(source["type"].get("environment")) + if source["type"] == "environment" and "path" in source: + env_dir = ev.as_env_dir(source["path"]) active_env = ev.active_environment() if active_env and env_dir in active_env.included_concrete_envs: # If environment is included as a concrete environment, use the local copy diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index f82cee10d7..87941de137 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -1941,7 +1941,7 @@ def configure_reuse(reuse_mode, combined_env) -> Optional[ev.Environment]: elif reuse_mode == "from_environment": _config = {"concretizer": {"reuse": {"from": [{"type": "environment"}]}}} elif reuse_mode == "from_environment_test1": - _config = {"concretizer": {"reuse": {"from": [{"type": {"environment": "test1"}}]}}} + _config = {"concretizer": {"reuse": {"from": [{"type": "environment", "path": "test1"}]}}} elif reuse_mode == "from_environment_external_test": # Create a new environment called external_test that enables the "debug" # The default is "~debug" @@ -1957,12 +1957,12 @@ def configure_reuse(reuse_mode, combined_env) -> Optional[ev.Environment]: # mpich@3.0 but with include concrete the mpich@1.0 +debug version from the # "external_test" environment will be used. _config = { - "concretizer": {"reuse": {"from": [{"type": {"environment": "external_test"}}]}}, + "concretizer": {"reuse": {"from": [{"type": "environment", "path": "external_test"}]}}, "packages": {"mpich": {"require": ["+debug"]}}, } elif reuse_mode == "from_environment_raise": _config = { - "concretizer": {"reuse": {"from": [{"type": {"environment": "not-a-real-env"}}]}} + "concretizer": {"reuse": {"from": [{"type": "environment", "path": "not-a-real-env"}]}} } # Disable unification in these tests to avoid confusing reuse due to unification using an # include concrete spec vs reuse due to the reuse configuration |