Skip to content

Commit

Permalink
Merge pull request #1787 from buildtesters/disable_module_check_durin…
Browse files Browse the repository at this point in the history
…g_validation

disable module check during validation
  • Loading branch information
shahzebsiddiqui authored Jun 14, 2024
2 parents a868fb1 + e131aef commit a2025e4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion buildtest/cli/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def find_compilers(self):

self.moduletool = self.configuration.target_config.get("moduletool")

if self.moduletool == "N/A" or not self.moduletool:
if self.moduletool == "none" or not self.moduletool:
raise ConfigurationError(
self.configuration.config,
self.configuration.file,
Expand Down
5 changes: 2 additions & 3 deletions buildtest/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def view_system(configuration):
console.print(table)


def validate_config(configuration, moduletool):
def validate_config(configuration):
"""This method implements ``buildtest config validate`` which attempts to
validate buildtest schema file `settings.schema.json <https://github.com/buildtesters/buildtest/blob/devel/buildtest/schemas/settings.schema.json>`_.
If it's not validate an exception is raised which could be
Expand All @@ -147,14 +147,13 @@ def validate_config(configuration, moduletool):
Args:
configuration (buildtest.config.SiteConfiguration): An instance of SiteConfiguration class
moduletool (str): Name of moduletool for validating module system
Raises:
SystemExit: If exception is raised during validating configuration file.
"""

try:
configuration.validate(moduletool=moduletool)
configuration.validate()
except (ValidationError, ConfigurationError) as err:
print(err)
raise sys.exit(f"{configuration.file} is not valid")
Expand Down
18 changes: 2 additions & 16 deletions buildtest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,8 @@ def detect_system(self):
f"Based on current system hostname: {hostname} we cannot find a matching system {list(self.systems)} based on current hostnames: {host_lookup} ",
)

def validate(self, moduletool=None):
"""This method validates the site configuration with schema.
Args:
moduletool (bool, optional): Check whether module system (Lmod, environment-modules) match what is specified in configuration file. Valid options are ``Lmod``, ``environment-modules``
"""
def validate(self):
"""This method validates the site configuration with schema."""

logger.debug(f"Loading default settings schema: {DEFAULT_SETTINGS_SCHEMA}")
config_schema = load_schema(DEFAULT_SETTINGS_SCHEMA)
Expand All @@ -152,16 +148,6 @@ def validate(self, moduletool=None):

self._executor_check()

if (
self.target_config.get("moduletool") != "none"
and self.target_config.get("moduletool") != moduletool
):
raise ConfigurationError(
self.config,
self.file,
f"There is a module tool mismatch, we have detected '{moduletool}' but configuration property 'moduletool' specifies '{self.target_config['moduletool']}'",
)

def _executor_check(self):
"""Validate executors"""

Expand Down
2 changes: 1 addition & 1 deletion buildtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def setup(args):
)
configuration = SiteConfiguration(config_file, verbose=args.verbose)
configuration.detect_system()
configuration.validate(moduletool=system.system["moduletool"])
configuration.validate()

if args.verbose:
console.print("Finish configuration initialization", style="bold blue")
Expand Down
10 changes: 5 additions & 5 deletions tests/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

configuration = SiteConfiguration(verbose=True)
configuration.detect_system()
configuration.validate(moduletool=system.system["moduletool"])
configuration.validate()


@pytest.mark.cli
Expand All @@ -50,7 +50,7 @@ def test_container_executor():
)
config = SiteConfiguration(settings_file=settings_file)
config.detect_system()
config.validate(moduletool=system.system["moduletool"])
config.validate()


def test_remove_executors():
Expand All @@ -60,7 +60,7 @@ def test_remove_executors():
print(temp_config_file.name)
config = SiteConfiguration(settings_file=temp_config_file.name)
config.detect_system()
configuration.validate(moduletool=system.system["moduletool"])
configuration.validate()

remove_executors(config, executor_names=["generic.local.bash", "generic.local.sh"])

Expand Down Expand Up @@ -91,7 +91,7 @@ def test_valid_config_schemas():

@pytest.mark.cli
def test_config_validate():
validate_config(configuration=configuration, moduletool=system.system["moduletool"])
validate_config(configuration=configuration)


@pytest.mark.cli
Expand All @@ -106,7 +106,7 @@ class TestProfiles:

buildtest_config = SiteConfiguration(settings_file=tf.name)
buildtest_config.detect_system()
buildtest_config.validate(moduletool=system.system["moduletool"])
buildtest_config.validate()

cmd = BuildTest(
configuration=buildtest_config, tags=["python"], save_profile="python"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_nersc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestNersc:

bc = SiteConfiguration(settings_file)
bc.detect_system()
bc.validate(moduletool="lmod")
bc.validate()
BuildspecCache(rebuild=True, configuration=bc)

def test_slurm_hostname(self):
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_compiler_remove(self):

config = SiteConfiguration(tf.name)
config.detect_system()
config.validate(moduletool="lmod")
config.validate()

compilers = BuildtestCompilers(configuration=config)
# remove one compiler from configuration
Expand Down
4 changes: 2 additions & 2 deletions tests/test_summit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_summit():

bc = SiteConfiguration(settings_file)
bc.detect_system()
bc.validate(moduletool="lmod")
bc.validate()
BuildspecCache(rebuild=True, configuration=bc)

examples_dir = os.path.join(here, "examples", "summit")
Expand All @@ -46,7 +46,7 @@ def test_compilers_find_ascent():

config = SiteConfiguration(settings_file)
config.detect_system()
config.validate(moduletool="lmod")
config.validate()

# testing buildtest config compilers find
bc = BuildtestCompilers(configuration=config)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_torque.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_torque():

bc = SiteConfiguration(settings_file)
bc.detect_system()
bc.validate(moduletool="environment-modules")
bc.validate()

cmd = BuildTest(
configuration=bc,
Expand Down Expand Up @@ -57,4 +57,4 @@ def test_invalid_executor():

bc = SiteConfiguration(settings_file)
bc.detect_system()
bc.validate(moduletool="environment-modules")
bc.validate()

0 comments on commit a2025e4

Please sign in to comment.