Remove warning for custom module configuration, when no module is enabled (#40358)

The warning was added in v0.20 and was slated for removal in v0.21
This commit is contained in:
Massimiliano Culpo 2023-10-07 09:21:04 +02:00 committed by GitHub
parent 6c1868f8ae
commit 28c49930e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 47 deletions

View file

@ -11,7 +11,6 @@
def _for_each_enabled(spec, method_name, explicit=None): def _for_each_enabled(spec, method_name, explicit=None):
"""Calls a method for each enabled module""" """Calls a method for each enabled module"""
spack.modules.ensure_modules_are_enabled_or_warn()
set_names = set(spack.config.get("modules", {}).keys()) set_names = set(spack.config.get("modules", {}).keys())
for name in set_names: for name in set_names:
enabled = spack.config.get("modules:%s:enable" % name) enabled = spack.config.get("modules:%s:enable" % name)

View file

@ -7,15 +7,10 @@
include Tcl non-hierarchical modules, Lua hierarchical modules, and others. include Tcl non-hierarchical modules, Lua hierarchical modules, and others.
""" """
from .common import disable_modules, ensure_modules_are_enabled_or_warn from .common import disable_modules
from .lmod import LmodModulefileWriter from .lmod import LmodModulefileWriter
from .tcl import TclModulefileWriter from .tcl import TclModulefileWriter
__all__ = [ __all__ = ["TclModulefileWriter", "LmodModulefileWriter", "disable_modules"]
"TclModulefileWriter",
"LmodModulefileWriter",
"disable_modules",
"ensure_modules_are_enabled_or_warn",
]
module_types = {"tcl": TclModulefileWriter, "lmod": LmodModulefileWriter} module_types = {"tcl": TclModulefileWriter, "lmod": LmodModulefileWriter}

View file

@ -33,10 +33,8 @@
import datetime import datetime
import inspect import inspect
import os.path import os.path
import pathlib
import re import re
import string import string
import warnings
from typing import Optional from typing import Optional
import llnl.util.filesystem import llnl.util.filesystem
@ -820,43 +818,6 @@ def verbose(self):
return self.conf.verbose return self.conf.verbose
def ensure_modules_are_enabled_or_warn():
"""Ensures that, if a custom configuration file is found with custom configuration for the
default tcl module set, then tcl module file generation is enabled. Otherwise, a warning
is emitted.
"""
# TODO (v0.21 - Remove this function)
# Check if TCL module generation is enabled, return early if it is
enabled = spack.config.get("modules:default:enable", [])
if "tcl" in enabled:
return
# Check if we have custom TCL module sections
for scope in spack.config.CONFIG.file_scopes:
# Skip default configuration
if scope.name.startswith("default"):
continue
data = spack.config.get("modules:default:tcl", scope=scope.name)
if data:
config_file = pathlib.Path(scope.path)
if not scope.name.startswith("env"):
config_file = config_file / "modules.yaml"
break
else:
return
# If we are here we have a custom "modules" section in "config_file"
msg = (
f"detected custom TCL modules configuration in {config_file}, while TCL module file "
f"generation for the default module set is disabled. "
f"In Spack v0.20 module file generation has been disabled by default. To enable "
f"it run:\n\n\t$ spack config add 'modules:default:enable:[tcl]'\n"
)
warnings.warn(msg)
class BaseModuleFileWriter: class BaseModuleFileWriter:
def __init__(self, spec, module_set_name, explicit=None): def __init__(self, spec, module_set_name, explicit=None):
self.spec = spec self.spec = spec