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
This commit is contained in:
parent
19e3ab83cf
commit
133895e785
@ -32,24 +32,15 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"oneOf": [
|
"type": "string",
|
||||||
{
|
"enum": [
|
||||||
"type": "string",
|
"local",
|
||||||
"enum": [
|
"buildcache",
|
||||||
"local",
|
"external",
|
||||||
"buildcache",
|
"environment",
|
||||||
"environment",
|
],
|
||||||
"external",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"environment": {"type": "string"}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
"path": {"type": "string"},
|
||||||
"include": LIST_OF_SPECS,
|
"include": LIST_OF_SPECS,
|
||||||
"exclude": LIST_OF_SPECS,
|
"exclude": LIST_OF_SPECS,
|
||||||
},
|
},
|
||||||
|
@ -4103,8 +4103,8 @@ def __init__(self, configuration: spack.config.Configuration) -> None:
|
|||||||
for source in reuse_yaml.get("from", default_sources):
|
for source in reuse_yaml.get("from", default_sources):
|
||||||
include = source.get("include", default_include)
|
include = source.get("include", default_include)
|
||||||
exclude = source.get("exclude", default_exclude)
|
exclude = source.get("exclude", default_exclude)
|
||||||
if isinstance(source["type"], dict):
|
if source["type"] == "environment" and "path" in source:
|
||||||
env_dir = ev.as_env_dir(source["type"].get("environment"))
|
env_dir = ev.as_env_dir(source["path"])
|
||||||
active_env = ev.active_environment()
|
active_env = ev.active_environment()
|
||||||
if active_env and env_dir in active_env.included_concrete_envs:
|
if active_env and env_dir in active_env.included_concrete_envs:
|
||||||
# If environment is included as a concrete environment, use the local copy
|
# If environment is included as a concrete environment, use the local copy
|
||||||
|
@ -1941,7 +1941,7 @@ def configure_reuse(reuse_mode, combined_env) -> Optional[ev.Environment]:
|
|||||||
elif reuse_mode == "from_environment":
|
elif reuse_mode == "from_environment":
|
||||||
_config = {"concretizer": {"reuse": {"from": [{"type": "environment"}]}}}
|
_config = {"concretizer": {"reuse": {"from": [{"type": "environment"}]}}}
|
||||||
elif reuse_mode == "from_environment_test1":
|
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":
|
elif reuse_mode == "from_environment_external_test":
|
||||||
# Create a new environment called external_test that enables the "debug"
|
# Create a new environment called external_test that enables the "debug"
|
||||||
# The default is "~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
|
# mpich@3.0 but with include concrete the mpich@1.0 +debug version from the
|
||||||
# "external_test" environment will be used.
|
# "external_test" environment will be used.
|
||||||
_config = {
|
_config = {
|
||||||
"concretizer": {"reuse": {"from": [{"type": {"environment": "external_test"}}]}},
|
"concretizer": {"reuse": {"from": [{"type": "environment", "path": "external_test"}]}},
|
||||||
"packages": {"mpich": {"require": ["+debug"]}},
|
"packages": {"mpich": {"require": ["+debug"]}},
|
||||||
}
|
}
|
||||||
elif reuse_mode == "from_environment_raise":
|
elif reuse_mode == "from_environment_raise":
|
||||||
_config = {
|
_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
|
# Disable unification in these tests to avoid confusing reuse due to unification using an
|
||||||
# include concrete spec vs reuse due to the reuse configuration
|
# include concrete spec vs reuse due to the reuse configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user