Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions reframe/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions reframe/core/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
8 changes: 7 additions & 1 deletion reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
12 changes: 12 additions & 0 deletions unittests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down