Skip to content

Commit

Permalink
remove deprecated top-level module config (spack#33828)
Browse files Browse the repository at this point in the history
* remove deprecated top-level module config per deprecation in 0.18
  • Loading branch information
becker33 authored Nov 11, 2022
1 parent 3437926 commit f11778b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 66 deletions.
3 changes: 0 additions & 3 deletions lib/spack/spack/modules/lmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
def configuration(module_set_name):
config_path = "modules:%s:lmod" % module_set_name
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


Expand Down
3 changes: 0 additions & 3 deletions lib/spack/spack/modules/tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
def configuration(module_set_name):
config_path = "modules:%s:tcl" % module_set_name
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


Expand Down
62 changes: 2 additions & 60 deletions lib/spack/spack/schema/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
.. literalinclude:: _spack_root/lib/spack/spack/schema/modules.py
:lines: 13-
"""
import warnings

import spack.schema.environment
import spack.schema.projections

Expand All @@ -26,9 +24,7 @@
)

#: Matches a valid name for a module set
valid_module_set_name = (
r"^(?!arch_folder$|lmod$|roots$|enable$|prefix_inspections$|" r"tcl$|use_view$)\w[\w-]*$"
)
valid_module_set_name = r"^(?!prefix_inspections$)\w[\w-]*$"

#: Matches an anonymous spec, i.e. a spec without a root name
anonymous_spec_regex = r"^[\^@%+~]"
Expand Down Expand Up @@ -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 = {
"modules": {
Expand All @@ -187,13 +174,6 @@ def deprecation_msg_default_module_set(instance, props):
"additionalProperties": False,
"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,
},
}
}
Expand Down Expand Up @@ -249,39 +229,6 @@ def update_keys(data, key_translations):
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):
"""Update the data in place to remove deprecated properties.
Expand All @@ -291,10 +238,5 @@ def update(data):
Returns:
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
changed |= update_keys(data, exclude_include_translations)

return changed
return update_keys(data, exclude_include_translations)

0 comments on commit f11778b

Please sign in to comment.