From b32e76d0f01139fdb789297250b93e7c482e07ed Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 4 Apr 2024 10:18:44 +0200 Subject: [PATCH 01/14] Add env resources --- reframe/core/environments.py | 14 +++++++++++++- reframe/core/pipeline.py | 17 +++++++++++++++-- reframe/core/systems.py | 30 +++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/reframe/core/environments.py b/reframe/core/environments.py index e5a91f9af0..1db7c61b3f 100644 --- a/reframe/core/environments.py +++ b/reframe/core/environments.py @@ -39,7 +39,8 @@ class Environment(jsonext.JSONSerializable): ''' def __init__(self, name, modules=None, env_vars=None, - extras=None, features=None, prepare_cmds=None): + extras=None, features=None, prepare_cmds=None, + resources=None): modules = modules or [] env_vars = env_vars or [] self._name = name @@ -57,6 +58,7 @@ def __init__(self, name, modules=None, env_vars=None, self._extras = extras or {} self._features = features or [] self._prepare_cmds = prepare_cmds or [] + self._resources = resources or {} @property def name(self): @@ -146,6 +148,16 @@ def prepare_cmds(self): ''' return util.SequenceView(self._prepare_cmds) + @property + def resources(self): + '''The resources associated with this environment. + + .. versionadded:: 4.6.0 + + :type: :class:`Dict[str, object]` + ''' + return self._resources + def __eq__(self, other): if not isinstance(other, type(self)): return NotImplemented diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index c6b13dbcae..e15f2d54be 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1859,7 +1859,10 @@ def compile(self): # build_job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - self._build_job.options = resources_opts + self._build_job.options + env_resources_opts = self._map_env_resources_to_jobopts() + self._build_job.options = ( + env_resources_opts + resources_opts + self._build_job.options + ) with osext.change_dir(self._stagedir): # Prepare build job build_commands = [ @@ -2007,7 +2010,10 @@ def _get_cp_env(): # job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - self._job.options = resources_opts + self._job.options + env_resources_opts = self._map_env_resources_to_jobopts() + self._job.options = ( + env_resources_opts + resources_opts + self._job.options + ) with osext.change_dir(self._stagedir): try: self.logger.debug('Generating the run script') @@ -2037,6 +2043,13 @@ def _map_resources_to_jobopts(self): return resources_opts + def _map_env_resources_to_jobopts(self): + resources_opts = [] + for r, v in self._current_environ.resources.items(): + resources_opts += self._current_partition.get_env_resource(r, **v) + + return resources_opts + @final def compile_complete(self): '''Check if the build phase has completed. diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 7c5a785e31..a74f3423a6 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -167,7 +167,7 @@ class SystemPartition(jsonext.JSONSerializable): def __init__(self, *, parent, name, sched_type, launcher_type, descr, access, container_runtime, container_environs, resources, local_env, environs, max_jobs, prepare_cmds, - processor, devices, extras, features, time_limit): + processor, devices, extras, features, time_limit, env_resources): getlogger().debug(f'Initializing system partition {name!r}') self._parent_system = parent self._name = name @@ -183,6 +183,7 @@ def __init__(self, *, parent, name, sched_type, launcher_type, self._max_jobs = max_jobs self._prepare_cmds = prepare_cmds self._resources = {r['name']: r['options'] for r in resources} + self._env_resources = {r['name']: r['options'] for r in env_resources} self._processor = ProcessorInfo(processor) self._devices = [DeviceInfo(d) for d in devices] self._extras = extras @@ -349,6 +350,21 @@ def get_resource(self, name, **values): return ret + def get_env_resource(self, name, **values): + '''Instantiate managed environment resource ``name`` with ``value``. + + :meta private: + ''' + + ret = [] + for r in self._env_resources.get(name, []): + try: + ret.append(r.format(**values)) + except KeyError: + pass + + return ret + def environment(self, name): '''Return the partition environment named ``name``.''' @@ -452,7 +468,14 @@ def json(self): 'options': options } for name, options in self._resources.items() - ] + ], + 'env_resources': [ + { + 'name': name, + 'options': options + } + for name, options in self._env_resources.items() + ], } def __str__(self): @@ -576,7 +599,8 @@ def create(cls, site_config): devices=site_config.get(f'{partid}/devices'), extras=site_config.get(f'{partid}/extras'), features=site_config.get(f'{partid}/features'), - time_limit=site_config.get(f'{partid}/time_limit') + time_limit=site_config.get(f'{partid}/time_limit'), + env_resources=site_config.get(f'{partid}/env_resources') ) ) From e5a1aa630671810d1369d108119dff844b8acacc Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 4 Apr 2024 11:22:39 +0200 Subject: [PATCH 02/14] Small fix --- reframe/core/environments.py | 26 +++++++++++++------------- reframe/core/systems.py | 3 ++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/reframe/core/environments.py b/reframe/core/environments.py index 1db7c61b3f..bb8f3cdb93 100644 --- a/reframe/core/environments.py +++ b/reframe/core/environments.py @@ -39,8 +39,7 @@ class Environment(jsonext.JSONSerializable): ''' def __init__(self, name, modules=None, env_vars=None, - extras=None, features=None, prepare_cmds=None, - resources=None): + extras=None, features=None, prepare_cmds=None): modules = modules or [] env_vars = env_vars or [] self._name = name @@ -58,7 +57,6 @@ def __init__(self, name, modules=None, env_vars=None, self._extras = extras or {} self._features = features or [] self._prepare_cmds = prepare_cmds or [] - self._resources = resources or {} @property def name(self): @@ -148,16 +146,6 @@ def prepare_cmds(self): ''' return util.SequenceView(self._prepare_cmds) - @property - def resources(self): - '''The resources associated with this environment. - - .. versionadded:: 4.6.0 - - :type: :class:`Dict[str, object]` - ''' - return self._resources - def __eq__(self, other): if not isinstance(other, type(self)): return NotImplemented @@ -254,6 +242,7 @@ def __init__(self, cxxflags=None, fflags=None, ldflags=None, + resources=None, **kwargs): super().__init__(name, modules, env_vars, extras, features, prepare_cmds) @@ -266,6 +255,7 @@ def __init__(self, self._cxxflags = cxxflags or [] self._fflags = fflags or [] self._ldflags = ldflags or [] + self._resources = resources or {} @property def cc(self): @@ -338,3 +328,13 @@ def nvcc(self): :type: :class:`str` ''' return self._nvcc + + @property + def resources(self): + '''The resources associated with this environment. + + .. versionadded:: 4.6.0 + + :type: :class:`Dict[str, object]` + ''' + return self._resources diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 9ac33eda25..632256a3af 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -572,7 +572,8 @@ def create(cls, site_config): cflags=site_config.get(f'environments/@{e}/cflags'), cxxflags=site_config.get(f'environments/@{e}/cxxflags'), fflags=site_config.get(f'environments/@{e}/fflags'), - ldflags=site_config.get(f'environments/@{e}/ldflags') + ldflags=site_config.get(f'environments/@{e}/ldflags'), + resources=site_config.get(f'environments/@{e}/resources') ) for e in site_config.get(f'{partid}/environs') if any(re.match(pattern, e) for pattern in env_patt) ] From b1584a9774dc133de0700d8b7196290bb88b3c75 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 4 Apr 2024 11:36:53 +0200 Subject: [PATCH 03/14] Split line --- reframe/core/systems.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 632256a3af..8fe0e9fe1b 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -167,7 +167,8 @@ class SystemPartition(jsonext.JSONSerializable): def __init__(self, *, parent, name, sched_type, launcher_type, descr, access, container_runtime, container_environs, resources, local_env, environs, max_jobs, prepare_cmds, - processor, devices, extras, features, time_limit, env_resources): + processor, devices, extras, features, time_limit, + env_resources): getlogger().debug(f'Initializing system partition {name!r}') self._parent_system = parent self._name = name From be25706cd868a996d49626ed91e9c171a84ab67f Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 4 Apr 2024 11:42:11 +0200 Subject: [PATCH 04/14] Add schema --- reframe/schemas/config.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/reframe/schemas/config.json b/reframe/schemas/config.json index 01f3b9e7ef..b1894fe201 100644 --- a/reframe/schemas/config.json +++ b/reframe/schemas/config.json @@ -350,6 +350,21 @@ "required": ["name"], "additionalProperties": false } + }, + "env_resources": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "options": { + "type": "array", + "items": {"type": "string"} + } + }, + "required": ["name"], + "additionalProperties": false + } } }, "required": ["name", "scheduler", "launcher"], @@ -409,6 +424,16 @@ "type": "array", "items": {"$ref": "#/defs/alphanum_string"} }, + "resources": { + "type": "object", + "propertyNames": { + "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$" + }, + "additionalProperties": { + "type": "object", + "additionalProperties": true + } + }, "target_systems": {"$ref": "#/defs/system_ref"} }, "required": ["name"], @@ -615,6 +640,8 @@ "systems/partitions/features": [], "systems/partitions/resources": [], "systems/partitions/resources/options": [], + "systems/partitions/env_resources": [], + "systems/partitions/env_resources/options": [], "systems/partitions/modules": [], "systems/partitions/env_vars": [], "systems/partitions/variables": [], From 257ac383be6df4a1f1d068b6b5858627c3bcd7d0 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Wed, 10 Apr 2024 11:01:12 +0200 Subject: [PATCH 05/14] Add config + a test --- docs/config_reference.rst | 33 +++++++++++++++++++++++++- unittests/resources/config/settings.py | 9 +++++++ unittests/test_config.py | 6 +++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index 6de312ea9b..78d096fef0 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -684,7 +684,7 @@ ReFrame can launch containerized applications, but you need to configure properl Custom Job Scheduler Resources ============================== -ReFrame allows you to define custom scheduler resources for each partition that you can then transparently access through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a regression test. +ReFrame allows you to define custom scheduler resources for each partition that you can then transparently access through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a regression test or the environment. .. py:attribute:: systems.partitions.resources.name @@ -766,6 +766,27 @@ ReFrame allows you to define custom scheduler resources for each partition that The backend assumes a ``qsub`` option, if the options passed in these attributes start with a ``-``. +.. py:attribute:: systems.partitions.env_resources.name + + :required: Yes + + The name of this resources. + This name will be used to request this resource in a programming environment :attr:`~environments.resources`. + + .. versionadded:: 4.6 + + +.. py:attribute:: systems.partitions.env_resources.options + + :required: No + :default: ``[]`` + + A list of options to be passed to this partition’s job scheduler. + This is very similar to the :attr:`~config.systems.partitions.resources.options` parameter, but it is used to define resources that are specific to a programming environment. + + .. versionadded:: 4.6 + + Environment Configuration ========================= @@ -948,6 +969,16 @@ They are associated with `system partitions <#system-partition-configuration>`__ It first looks for definitions for the current partition, then for the containing system and, finally, for global definitions (the ``*`` pseudo-system). +.. py:attribute:: environments.resources + + :required: No + :default: ``{}`` + + This is similar to a regression test's :attr:`~reframe.core.pipeline.RegressionTest.extra_resources`. + + .. versionadded:: 4.6 + + .. _logging-config-reference: Logging Configuration diff --git a/unittests/resources/config/settings.py b/unittests/resources/config/settings.py index 72f19e45a7..094dc361b0 100644 --- a/unittests/resources/config/settings.py +++ b/unittests/resources/config/settings.py @@ -63,6 +63,15 @@ def hostname(): ] } ], + 'env_resources': [ + { + 'name': 'uenv', + 'options': [ + '--mount={mount}', + '--file={file}' + ], + }, + ], 'features': ['cuda', 'mpi'], 'extras': { 'gpu_arch': 'a100' diff --git a/unittests/test_config.py b/unittests/test_config.py index 6a89043b47..de9e87a4fe 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -461,6 +461,12 @@ def test_system_create(site_config): assert resources_spec == ['#DW jobdw capacity=100GB', '#DW stage_in source=/foo'] + env_resources_spec = partition.get_env_resource( + 'uenv', mount='mount_point', file='file_path' + ) + assert env_resources_spec == ['--mount=mount_point', + '--file=file_path'] + # Check processor info assert partition.processor.info is not None assert partition.processor.topology is not None From 06e8b936fbe9250969ddcad95e803e692434fba4 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Wed, 10 Apr 2024 11:03:04 +0200 Subject: [PATCH 06/14] Fix formatting --- unittests/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/test_config.py b/unittests/test_config.py index 2d7bfe8e0a..0bb294fa0b 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -465,7 +465,7 @@ def test_system_create(site_config): 'uenv', mount='mount_point', file='file_path' ) assert env_resources_spec == ['--mount=mount_point', - '--file=file_path'] + '--file=file_path'] # Check processor info assert partition.processor.info is not None From e41e17c358df795328f159f2e0ab705b33ca5642 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 11 Apr 2024 10:33:37 +0200 Subject: [PATCH 07/14] Update docs/config_reference.rst Co-authored-by: Theofilos Manitaras --- docs/config_reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index 60c64099c7..e56cff8a2c 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -782,7 +782,7 @@ ReFrame allows you to define custom scheduler resources for each partition that :default: ``[]`` A list of options to be passed to this partition’s job scheduler. - This is very similar to the :attr:`~config.systems.partitions.resources.options` parameter, but it is used to define resources that are specific to a programming environment. + This is very similar to the :attr:`~config.systems.partitions.resources.options` parameter, but it is used to define resources specific to a programming environment. .. versionadded:: 4.6 From 729f49be43d5901e3280609a3bda573da5dbaae1 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 11 Apr 2024 10:34:14 +0200 Subject: [PATCH 08/14] Update docs/config_reference.rst Co-authored-by: Theofilos Manitaras --- docs/config_reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index e56cff8a2c..75e7d9a9f3 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -684,7 +684,7 @@ ReFrame can launch containerized applications, but you need to configure properl Custom Job Scheduler Resources ============================== -ReFrame allows you to define custom scheduler resources for each partition that you can then transparently access through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a regression test or the environment. +ReFrame allows you to define custom scheduler resources for each partition/environment that can then be transparently accessed through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a regression test or the environment. .. py:attribute:: systems.partitions.resources.name From 296b164e0469f773ffad67e489deb49d5b3f6832 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 11 Apr 2024 10:34:19 +0200 Subject: [PATCH 09/14] Update docs/config_reference.rst Co-authored-by: Theofilos Manitaras --- docs/config_reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index 75e7d9a9f3..a5a48e8a7b 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -770,7 +770,7 @@ ReFrame allows you to define custom scheduler resources for each partition/envir :required: Yes - The name of this resources. + The name of the resources. This name will be used to request this resource in a programming environment :attr:`~environments.resources`. .. versionadded:: 4.6 From f5e8c41d44839796da1d1d9b5988974502b54a01 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Tue, 16 Apr 2024 12:27:05 +0200 Subject: [PATCH 10/14] Address PR comments --- docs/config_reference.rst | 21 ------------------- reframe/core/pipeline.py | 18 ++++++---------- reframe/core/systems.py | 29 ++------------------------ unittests/resources/config/settings.py | 6 ++---- unittests/test_config.py | 4 ++-- 5 files changed, 12 insertions(+), 66 deletions(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index c1cf1c2693..bb6a8c7095 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -771,27 +771,6 @@ ReFrame allows you to define custom scheduler resources for each partition that The backend assumes a ``qsub`` option, if the options passed in these attributes start with a ``-``. -.. py:attribute:: systems.partitions.env_resources.name - - :required: Yes - - The name of this resources. - This name will be used to request this resource in a programming environment :attr:`~environments.resources`. - - .. versionadded:: 4.6 - - -.. py:attribute:: systems.partitions.env_resources.options - - :required: No - :default: ``[]`` - - A list of options to be passed to this partition’s job scheduler. - This is very similar to the :attr:`~config.systems.partitions.resources.options` parameter, but it is used to define resources that are specific to a programming environment. - - .. versionadded:: 4.6 - - Environment Configuration ========================= diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 87f00fbf40..6cd9ad6d22 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1863,9 +1863,8 @@ def compile(self): # build_job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - env_resources_opts = self._map_env_resources_to_jobopts() self._build_job.options = ( - env_resources_opts + resources_opts + self._build_job.options + resources_opts + self._build_job.options ) with osext.change_dir(self._stagedir): # Prepare build job @@ -2014,9 +2013,8 @@ def _get_cp_env(): # job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - env_resources_opts = self._map_env_resources_to_jobopts() self._job.options = ( - env_resources_opts + resources_opts + self._job.options + resources_opts + self._job.options ) with osext.change_dir(self._stagedir): try: @@ -2042,18 +2040,14 @@ def _get_cp_env(): def _map_resources_to_jobopts(self): resources_opts = [] - for r, v in self.extra_resources.items(): + # Combine all resources into one dictionary, where extra_resources + # can overwrite _current_environ.resources + combined_resources = {**self._current_environ.resources, **self.extra_resources} + for r, v in combined_resources.items(): resources_opts += self._current_partition.get_resource(r, **v) return resources_opts - def _map_env_resources_to_jobopts(self): - resources_opts = [] - for r, v in self._current_environ.resources.items(): - resources_opts += self._current_partition.get_env_resource(r, **v) - - return resources_opts - @final def compile_complete(self): '''Check if the build phase has completed. diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 4dbb891c1e..95b8582605 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -167,8 +167,7 @@ class SystemPartition(jsonext.JSONSerializable): def __init__(self, *, parent, name, sched_type, launcher_type, descr, access, container_runtime, container_environs, resources, local_env, environs, max_jobs, prepare_cmds, - processor, devices, extras, features, time_limit, - env_resources): + processor, devices, extras, features, time_limit): getlogger().debug(f'Initializing system partition {name!r}') self._parent_system = parent self._name = name @@ -184,7 +183,6 @@ def __init__(self, *, parent, name, sched_type, launcher_type, self._max_jobs = max_jobs self._prepare_cmds = prepare_cmds self._resources = {r['name']: r['options'] for r in resources} - self._env_resources = {r['name']: r['options'] for r in env_resources} self._processor = ProcessorInfo(processor) self._devices = [DeviceInfo(d) for d in devices] self._extras = extras @@ -351,21 +349,6 @@ def get_resource(self, name, **values): return ret - def get_env_resource(self, name, **values): - '''Instantiate managed environment resource ``name`` with ``value``. - - :meta private: - ''' - - ret = [] - for r in self._env_resources.get(name, []): - try: - ret.append(r.format(**values)) - except KeyError: - pass - - return ret - def environment(self, name): '''Return the partition environment named ``name``.''' @@ -469,14 +452,7 @@ def json(self): 'options': options } for name, options in self._resources.items() - ], - 'env_resources': [ - { - 'name': name, - 'options': options - } - for name, options in self._env_resources.items() - ], + ] } def __str__(self): @@ -602,7 +578,6 @@ def create(cls, site_config): extras=site_config.get(f'{partid}/extras'), features=site_config.get(f'{partid}/features'), time_limit=site_config.get(f'{partid}/time_limit'), - env_resources=site_config.get(f'{partid}/env_resources') ) ) diff --git a/unittests/resources/config/settings.py b/unittests/resources/config/settings.py index 695f661f29..1d6879ffbf 100644 --- a/unittests/resources/config/settings.py +++ b/unittests/resources/config/settings.py @@ -61,16 +61,14 @@ def hostname(): '#DW jobdw capacity={capacity}', '#DW stage_in source={stagein_src}' ] - } - ], - 'env_resources': [ + }, { 'name': 'uenv', 'options': [ '--mount={mount}', '--file={file}' ], - }, + } ], 'features': ['cuda', 'mpi'], 'extras': { diff --git a/unittests/test_config.py b/unittests/test_config.py index 0bb294fa0b..0681c4645c 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -293,7 +293,7 @@ def test_select_subconfig(site_config): assert (site_config.get('systems/0/partitions/0/environs') == ['PrgEnv-gnu', 'builtin']) assert site_config.get('systems/0/partitions/0/descr') == 'GPU partition' - assert len(site_config.get('systems/0/partitions/0/resources')) == 2 + assert len(site_config.get('systems/0/partitions/0/resources')) == 3 assert (site_config.get('systems/0/partitions/0/resources/@gpu/name') == 'gpu') assert site_config.get('systems/0/partitions/0/modules') == [ @@ -461,7 +461,7 @@ def test_system_create(site_config): assert resources_spec == ['#DW jobdw capacity=100GB', '#DW stage_in source=/foo'] - env_resources_spec = partition.get_env_resource( + env_resources_spec = partition.get_resource( 'uenv', mount='mount_point', file='file_path' ) assert env_resources_spec == ['--mount=mount_point', From ed2ffd3a5119259432871a599e146a3e0de7c422 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Tue, 16 Apr 2024 12:31:47 +0200 Subject: [PATCH 11/14] Update reframe/core/environments.py Co-authored-by: Vasileios Karakasis --- reframe/core/environments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reframe/core/environments.py b/reframe/core/environments.py index bb8f3cdb93..e2543e0a33 100644 --- a/reframe/core/environments.py +++ b/reframe/core/environments.py @@ -331,7 +331,7 @@ def nvcc(self): @property def resources(self): - '''The resources associated with this environment. + '''The scheduler resources associated with this environment. .. versionadded:: 4.6.0 From 2de71e02dfca3da4dba9ca933fbb92e9ae2133c4 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Tue, 16 Apr 2024 12:32:46 +0200 Subject: [PATCH 12/14] Update schema --- reframe/schemas/config.json | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/reframe/schemas/config.json b/reframe/schemas/config.json index e9fb914005..a3b028a0e0 100644 --- a/reframe/schemas/config.json +++ b/reframe/schemas/config.json @@ -351,21 +351,6 @@ "required": ["name"], "additionalProperties": false } - }, - "env_resources": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": {"type": "string"}, - "options": { - "type": "array", - "items": {"type": "string"} - } - }, - "required": ["name"], - "additionalProperties": false - } } }, "required": ["name", "scheduler", "launcher"], @@ -641,8 +626,6 @@ "systems/partitions/features": [], "systems/partitions/resources": [], "systems/partitions/resources/options": [], - "systems/partitions/env_resources": [], - "systems/partitions/env_resources/options": [], "systems/partitions/modules": [], "systems/partitions/env_vars": [], "systems/partitions/variables": [], From 769c0d48bb7f121f42c9da5adaefccaec39327f6 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Tue, 16 Apr 2024 12:36:27 +0200 Subject: [PATCH 13/14] Fix formatting --- reframe/core/pipeline.py | 13 ++++++------- reframe/core/systems.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 6cd9ad6d22..af752c0e5e 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1863,9 +1863,7 @@ def compile(self): # build_job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - self._build_job.options = ( - resources_opts + self._build_job.options - ) + self._build_job.options = resources_opts + self._build_job.options with osext.change_dir(self._stagedir): # Prepare build job build_commands = [ @@ -2013,9 +2011,7 @@ def _get_cp_env(): # job_opts. We want any user supplied options to be able to # override those set by the framework. resources_opts = self._map_resources_to_jobopts() - self._job.options = ( - resources_opts + self._job.options - ) + self._job.options = resources_opts + self._job.options with osext.change_dir(self._stagedir): try: self.logger.debug('Generating the run script') @@ -2042,7 +2038,10 @@ def _map_resources_to_jobopts(self): resources_opts = [] # Combine all resources into one dictionary, where extra_resources # can overwrite _current_environ.resources - combined_resources = {**self._current_environ.resources, **self.extra_resources} + combined_resources = { + **self._current_environ.resources, + **self.extra_resources + } for r, v in combined_resources.items(): resources_opts += self._current_partition.get_resource(r, **v) diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 95b8582605..3202d9c684 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -577,7 +577,7 @@ def create(cls, site_config): devices=site_config.get(f'{partid}/devices'), extras=site_config.get(f'{partid}/extras'), features=site_config.get(f'{partid}/features'), - time_limit=site_config.get(f'{partid}/time_limit'), + time_limit=site_config.get(f'{partid}/time_limit') ) ) From a278d9ad54ef28487f7589d35ab9755c36078726 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 19 Apr 2024 00:44:33 +0200 Subject: [PATCH 14/14] Apply suggestions from code review --- docs/config_reference.rst | 6 ++++-- unittests/resources/config/settings.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/config_reference.rst b/docs/config_reference.rst index 09986df57c..694bf956fd 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -689,7 +689,7 @@ ReFrame can launch containerized applications, but you need to configure properl Custom Job Scheduler Resources ============================== -ReFrame allows you to define custom scheduler resources for each partition/environment that can then be transparently accessed through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a regression test or the environment. +ReFrame allows you to define custom scheduler resources for each partition that can then be transparently accessed through the :attr:`~reframe.core.pipeline.RegressionTest.extra_resources` attribute of a test or from an environment. .. py:attribute:: systems.partitions.resources.name @@ -958,7 +958,9 @@ They are associated with `system partitions <#system-partition-configuration>`__ :required: No :default: ``{}`` - This is similar to a regression test's :attr:`~reframe.core.pipeline.RegressionTest.extra_resources`. + Scheduler resources associated with this environments. + + This is the equivalent of a test's :attr:`~reframe.core.pipeline.RegressionTest.extra_resources`. .. versionadded:: 4.6 diff --git a/unittests/resources/config/settings.py b/unittests/resources/config/settings.py index 1d6879ffbf..b888e0fbfc 100644 --- a/unittests/resources/config/settings.py +++ b/unittests/resources/config/settings.py @@ -67,7 +67,7 @@ def hostname(): 'options': [ '--mount={mount}', '--file={file}' - ], + ] } ], 'features': ['cuda', 'mpi'],