From e131aef20d155246d225cbbdb2d10494d66a60c5 Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 14 Jun 2024 12:14:36 -0400 Subject: [PATCH] remove moduletool argument from method to disable module sanity check and raise exception during validation --- buildtest/cli/compilers.py | 2 +- buildtest/cli/config.py | 5 ++--- buildtest/config.py | 18 ++---------------- buildtest/main.py | 2 +- tests/cli/test_config.py | 10 +++++----- tests/test_nersc.py | 4 ++-- tests/test_summit.py | 4 ++-- tests/test_torque.py | 4 ++-- 8 files changed, 17 insertions(+), 32 deletions(-) diff --git a/buildtest/cli/compilers.py b/buildtest/cli/compilers.py index 58fa043f9..4cf3267d8 100644 --- a/buildtest/cli/compilers.py +++ b/buildtest/cli/compilers.py @@ -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, diff --git a/buildtest/cli/config.py b/buildtest/cli/config.py index d5d327a06..d02ac2a31 100644 --- a/buildtest/cli/config.py +++ b/buildtest/cli/config.py @@ -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 `_. If it's not validate an exception is raised which could be @@ -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") diff --git a/buildtest/config.py b/buildtest/config.py index 4d901d635..97c479f40 100644 --- a/buildtest/config.py +++ b/buildtest/config.py @@ -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) @@ -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""" diff --git a/buildtest/main.py b/buildtest/main.py index be8611134..6f8f1ab03 100644 --- a/buildtest/main.py +++ b/buildtest/main.py @@ -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") diff --git a/tests/cli/test_config.py b/tests/cli/test_config.py index 6997600a3..eda98e773 100644 --- a/tests/cli/test_config.py +++ b/tests/cli/test_config.py @@ -29,7 +29,7 @@ configuration = SiteConfiguration(verbose=True) configuration.detect_system() -configuration.validate(moduletool=system.system["moduletool"]) +configuration.validate() @pytest.mark.cli @@ -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(): @@ -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"]) @@ -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 @@ -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" diff --git a/tests/test_nersc.py b/tests/test_nersc.py index 919d86737..42d462686 100644 --- a/tests/test_nersc.py +++ b/tests/test_nersc.py @@ -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): @@ -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 diff --git a/tests/test_summit.py b/tests/test_summit.py index d6c634459..c403d3e1a 100644 --- a/tests/test_summit.py +++ b/tests/test_summit.py @@ -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") @@ -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) diff --git a/tests/test_torque.py b/tests/test_torque.py index 631441ee1..eb5009056 100644 --- a/tests/test_torque.py +++ b/tests/test_torque.py @@ -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, @@ -57,4 +57,4 @@ def test_invalid_executor(): bc = SiteConfiguration(settings_file) bc.detect_system() - bc.validate(moduletool="environment-modules") + bc.validate()