remove deprecated top-level module config (#33828)
* remove deprecated top-level module config per deprecation in 0.18
This commit is contained in:
parent
3437926cde
commit
f11778bb02
@ -26,9 +26,6 @@
|
|||||||
def configuration(module_set_name):
|
def configuration(module_set_name):
|
||||||
config_path = "modules:%s:lmod" % module_set_name
|
config_path = "modules:%s:lmod" % module_set_name
|
||||||
config = spack.config.get(config_path, {})
|
config = spack.config.get(config_path, {})
|
||||||
if not config and module_set_name == "default":
|
|
||||||
# return old format for backward compatibility
|
|
||||||
return spack.config.get("modules:lmod", {})
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
def configuration(module_set_name):
|
def configuration(module_set_name):
|
||||||
config_path = "modules:%s:tcl" % module_set_name
|
config_path = "modules:%s:tcl" % module_set_name
|
||||||
config = spack.config.get(config_path, {})
|
config = spack.config.get(config_path, {})
|
||||||
if not config and module_set_name == "default":
|
|
||||||
# return old format for backward compatibility
|
|
||||||
return spack.config.get("modules:tcl", {})
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
.. literalinclude:: _spack_root/lib/spack/spack/schema/modules.py
|
.. literalinclude:: _spack_root/lib/spack/spack/schema/modules.py
|
||||||
:lines: 13-
|
:lines: 13-
|
||||||
"""
|
"""
|
||||||
import warnings
|
|
||||||
|
|
||||||
import spack.schema.environment
|
import spack.schema.environment
|
||||||
import spack.schema.projections
|
import spack.schema.projections
|
||||||
|
|
||||||
@ -26,9 +24,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#: Matches a valid name for a module set
|
#: Matches a valid name for a module set
|
||||||
valid_module_set_name = (
|
valid_module_set_name = r"^(?!prefix_inspections$)\w[\w-]*$"
|
||||||
r"^(?!arch_folder$|lmod$|roots$|enable$|prefix_inspections$|" r"tcl$|use_view$)\w[\w-]*$"
|
|
||||||
)
|
|
||||||
|
|
||||||
#: Matches an anonymous spec, i.e. a spec without a root name
|
#: Matches an anonymous spec, i.e. a spec without a root name
|
||||||
anonymous_spec_regex = r"^[\^@%+~]"
|
anonymous_spec_regex = r"^[\^@%+~]"
|
||||||
@ -156,15 +152,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def deprecation_msg_default_module_set(instance, props):
|
|
||||||
return (
|
|
||||||
'Top-level properties "{0}" in module config are ignored as of Spack v0.18. '
|
|
||||||
'They should be set on the "default" module set. Run\n\n'
|
|
||||||
"\t$ spack config update modules\n\n"
|
|
||||||
"to update the file to the new format".format('", "'.join(instance))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Properties for inclusion into other schemas (requires definitions)
|
# Properties for inclusion into other schemas (requires definitions)
|
||||||
properties = {
|
properties = {
|
||||||
"modules": {
|
"modules": {
|
||||||
@ -187,13 +174,6 @@ def deprecation_msg_default_module_set(instance, props):
|
|||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"properties": module_config_properties,
|
"properties": module_config_properties,
|
||||||
},
|
},
|
||||||
# Deprecated top-level keys (ignored in 0.18 with a warning)
|
|
||||||
"^(arch_folder|lmod|roots|enable|tcl|use_view)$": {},
|
|
||||||
},
|
|
||||||
"deprecatedProperties": {
|
|
||||||
"properties": ["arch_folder", "lmod", "roots", "enable", "tcl", "use_view"],
|
|
||||||
"message": deprecation_msg_default_module_set,
|
|
||||||
"error": False,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,39 +229,6 @@ def update_keys(data, key_translations):
|
|||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|
||||||
def update_default_module_set(data):
|
|
||||||
"""Update module configuration to move top-level keys inside default module set.
|
|
||||||
|
|
||||||
This change was introduced in v0.18 (see 99083f1706 or #28659).
|
|
||||||
"""
|
|
||||||
changed = False
|
|
||||||
|
|
||||||
deprecated_top_level_keys = ("arch_folder", "lmod", "roots", "enable", "tcl", "use_view")
|
|
||||||
|
|
||||||
# Don't update when we already have a default module set
|
|
||||||
if "default" in data:
|
|
||||||
if any(key in data for key in deprecated_top_level_keys):
|
|
||||||
warnings.warn(
|
|
||||||
'Did not move top-level module properties into "default" '
|
|
||||||
'module set, because the "default" module set is already '
|
|
||||||
"defined"
|
|
||||||
)
|
|
||||||
return changed
|
|
||||||
|
|
||||||
default = {}
|
|
||||||
|
|
||||||
# Move deprecated top-level keys under "default" module set.
|
|
||||||
for key in deprecated_top_level_keys:
|
|
||||||
if key in data:
|
|
||||||
default[key] = data.pop(key)
|
|
||||||
|
|
||||||
if default:
|
|
||||||
changed = True
|
|
||||||
data["default"] = default
|
|
||||||
|
|
||||||
return changed
|
|
||||||
|
|
||||||
|
|
||||||
def update(data):
|
def update(data):
|
||||||
"""Update the data in place to remove deprecated properties.
|
"""Update the data in place to remove deprecated properties.
|
||||||
|
|
||||||
@ -291,10 +238,5 @@ def update(data):
|
|||||||
Returns:
|
Returns:
|
||||||
True if data was changed, False otherwise
|
True if data was changed, False otherwise
|
||||||
"""
|
"""
|
||||||
# deprecated top-level module config (everything in default module set)
|
|
||||||
changed = update_default_module_set(data)
|
|
||||||
|
|
||||||
# translate blacklist/whitelist to exclude/include
|
# translate blacklist/whitelist to exclude/include
|
||||||
changed |= update_keys(data, exclude_include_translations)
|
return update_keys(data, exclude_include_translations)
|
||||||
|
|
||||||
return changed
|
|
||||||
|
Loading…
Reference in New Issue
Block a user