diff --git a/reframe/core/config.py b/reframe/core/config.py index 291c47b3c0..8a5fc009f6 100644 --- a/reframe/core/config.py +++ b/reframe/core/config.py @@ -272,7 +272,8 @@ def validate(self): partition_names.add(partname) - def select_subconfig(self, system_fullname=None): + def select_subconfig(self, system_fullname=None, + ignore_resolve_errors=False): if (self._local_system is not None and self._local_system == system_fullname): return @@ -349,25 +350,29 @@ def select_subconfig(self, system_fullname=None): required_sections = self._schema['required'] for name in required_sections: if name not in self._local_config.keys(): - raise ConfigError(f"section '{name}' not defined " - f"for system '{system_fullname}'") + if not ignore_resolve_errors: + raise ConfigError( + f"section '{name}' not defined " + f"for system '{system_fullname}'" + ) # Verify that all environments defined by the system are defined for # the current system - sys_environs = { - *itertools.chain(*(p['environs'] - for p in systems[0]['partitions'])) - } - found_environs = { - e['name'] for e in self._local_config['environments'] - } - undefined_environs = sys_environs - found_environs - if undefined_environs: - env_descr = ', '.join(f"'{e}'" for e in undefined_environs) - raise ConfigError( - f"environments {env_descr} " - f"are not defined for '{system_fullname}'" - ) + if not ignore_resolve_errors: + sys_environs = { + *itertools.chain(*(p['environs'] + for p in systems[0]['partitions'])) + } + found_environs = { + e['name'] for e in self._local_config['environments'] + } + undefined_environs = sys_environs - found_environs + if undefined_environs: + env_descr = ', '.join(f"'{e}'" for e in undefined_environs) + raise ConfigError( + f"environments {env_descr} " + f"are not defined for '{system_fullname}'" + ) self._local_system = system_fullname diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 84151fa82e..a288dfaf9a 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -318,8 +318,10 @@ def create(cls, site_config): ) ) - # Restore configuration - site_config.select_subconfig(config_save) + # Restore configuration, but ignore unresolved sections or + # configuration parameters at the system level; if we came up to this + # point, then all is good at the partition level, which is enough. + site_config.select_subconfig(config_save, ignore_resolve_errors=True) return System( name=sysname, descr=site_config.get('systems/0/descr'), diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 367b1efa94..7501d1f864 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -463,7 +463,13 @@ def main(): site_config = config.load_config(converted) site_config.validate() - site_config.select_subconfig(options.system) + + # We ignore errors about unresolved sections or configuration + # parameters here, because they might be defined at the individual + # partition level and will be caught when we will instantiating + # internally the system and partitions later on. + site_config.select_subconfig(options.system, + ignore_resolve_errors=True) for err in options.update_config(site_config): printer.warning(str(err)) diff --git a/unittests/test_config.py b/unittests/test_config.py index 9c639e15bd..53f2530a78 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -201,6 +201,18 @@ def test_select_subconfig_undefined_environment(): site_config.select_subconfig() +def test_select_subconfig_ignore_resolve_errors(): + site_config = config.load_config('reframe/core/settings.py') + site_config['systems'][0]['partitions'][0]['environs'] += ['foo', 'bar'] + site_config.select_subconfig(ignore_resolve_errors=True) + + +def test_select_subconfig_ignore_no_section_errors(): + site_config = config.load_config('reframe/core/settings.py') + site_config['environments'][0]['target_systems'] = ['foo'] + site_config.select_subconfig(ignore_resolve_errors=True) + + def test_select_subconfig(): site_config = config.load_config('unittests/resources/settings.py') site_config.select_subconfig('testsys')