From 3c2ab3d27c8f88d496248674479e728087206fb0 Mon Sep 17 00:00:00 2001 From: Guido Petretto Date: Mon, 29 Jan 2024 17:47:43 +0100 Subject: [PATCH] rename qkwargs to scheduler_kwargs --- src/qtoolkit/core/data_objects.py | 11 +++++------ src/qtoolkit/io/pbs.py | 6 +++--- src/qtoolkit/io/slurm.py | 6 +++--- tests/core/test_data_objects.py | 2 +- tests/io/test_base.py | 14 +++++++++----- tests/io/test_shell.py | 2 +- tests/io/test_slurm.py | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/qtoolkit/core/data_objects.py b/src/qtoolkit/core/data_objects.py index 03381d0..124acb7 100644 --- a/src/qtoolkit/core/data_objects.py +++ b/src/qtoolkit/core/data_objects.py @@ -2,7 +2,6 @@ import abc from dataclasses import dataclass -from datetime import timedelta from pathlib import Path from qtoolkit.core.base import QTKEnum, QTKObject @@ -138,8 +137,8 @@ class QResources(QTKObject): gpus_per_job: int | None = None """Number of GPUs per job.""" - time_limit: int | timedelta | None = None - """Time limit for the job.""" + time_limit: int | None = None + """Time limit for the job. In seconds""" account: str | None = None """Account to charge the job to.""" @@ -171,8 +170,8 @@ class QResources(QTKObject): njobs: int | None = None """Number of jobs in a job array.""" - qkwargs: dict | None = None - """Additional keyword arguments to be passed to the queue manager.""" + scheduler_kwargs: dict | None = None + """Additional keyword arguments to be passed to the scheduler IO.""" def __post_init__(self): if self.process_placement is None: @@ -186,7 +185,7 @@ def __post_init__(self): "plus processes_per_node or only processes" ) raise UnsupportedResourcesError(msg) - self.qkwargs = self.qkwargs or {} + self.scheduler_kwargs = self.scheduler_kwargs or {} @classmethod def no_constraints(cls, processes, **kwargs): diff --git a/src/qtoolkit/io/pbs.py b/src/qtoolkit/io/pbs.py index 0341002..effec2e 100644 --- a/src/qtoolkit/io/pbs.py +++ b/src/qtoolkit/io/pbs.py @@ -435,8 +435,8 @@ def _convert_qresources(self, resources: QResources) -> dict: header_dict["mail_user"] = resources.email_address header_dict["mail_type"] = "abe" - if resources.qkwargs: - header_dict.update(resources.qkwargs) + if resources.scheduler_kwargs: + header_dict.update(resources.scheduler_kwargs) return header_dict @@ -457,6 +457,6 @@ def supported_qresources_keys(self) -> list: "nodes", "threads_per_process", "email_address", - "qkwargs", + "scheduler_kwargs", ] return supported diff --git a/src/qtoolkit/io/slurm.py b/src/qtoolkit/io/slurm.py index c5132ce..8254f2a 100644 --- a/src/qtoolkit/io/slurm.py +++ b/src/qtoolkit/io/slurm.py @@ -577,8 +577,8 @@ def _convert_qresources(self, resources: QResources) -> dict: header_dict["mail_user"] = resources.email_address header_dict["mail_type"] = "ALL" - if resources.qkwargs: - header_dict.update(resources.qkwargs) + if resources.scheduler_kwargs: + header_dict.update(resources.scheduler_kwargs) return header_dict @@ -600,6 +600,6 @@ def supported_qresources_keys(self) -> list: "threads_per_process", "gpus_per_job", "email_address", - "qkwargs", + "scheduler_kwargs", ] return supported diff --git a/tests/core/test_data_objects.py b/tests/core/test_data_objects.py index 8ff2ea0..08057fa 100644 --- a/tests/core/test_data_objects.py +++ b/tests/core/test_data_objects.py @@ -246,7 +246,7 @@ def test_msonable(self, test_utils): memory_per_thread=1024, processes=16, time_limit=86400, - qkwargs={"a": "b"}, + scheduler_kwargs={"a": "b"}, ) assert test_utils.is_msonable(qr1) qr2 = QResources.evenly_distributed(nodes=4, processes_per_node=8) diff --git a/tests/io/test_base.py b/tests/io/test_base.py index 5d86b06..09aa6a5 100644 --- a/tests/io/test_base.py +++ b/tests/io/test_base.py @@ -94,15 +94,15 @@ def _convert_qresources(self, resources: QResources) -> dict: if nodes: header_dict["nodes"] = nodes - if resources.qkwargs: - header_dict.update(resources.qkwargs) + if resources.scheduler_kwargs: + header_dict.update(resources.scheduler_kwargs) return header_dict @property def supported_qresources_keys(self) -> list: return [ - "qkwargs", + "scheduler_kwargs", "nodes", "processes_per_node", "process_placement", @@ -133,7 +133,9 @@ def test_generate_header(self, scheduler): res = QResources(processes=8) header = scheduler.generate_header(res) assert header == """#SPECCMD --processes=8""" - res = QResources(nodes=4, processes_per_node=16, qkwargs={"option2": "myopt2"}) + res = QResources( + nodes=4, processes_per_node=16, scheduler_kwargs={"option2": "myopt2"} + ) header = scheduler.generate_header(res) assert ( header @@ -147,7 +149,9 @@ def test_generate_header(self, scheduler): match=r"The following keys are not present in the template: tata, titi", ): res = QResources( - nodes=4, processes_per_node=16, qkwargs={"tata": "tata", "titi": "titi"} + nodes=4, + processes_per_node=16, + scheduler_kwargs={"tata": "tata", "titi": "titi"}, ) scheduler.generate_header(res) diff --git a/tests/io/test_shell.py b/tests/io/test_shell.py index c30f96a..254ef9e 100644 --- a/tests/io/test_shell.py +++ b/tests/io/test_shell.py @@ -204,7 +204,7 @@ def test_check_convert_qresources(self, shell_io): qr = QResources(processes=1) with pytest.raises( UnsupportedResourcesError, - match=r"Keys not supported: process_placement, processes, qkwargs", + match=r"Keys not supported: process_placement, processes, scheduler_kwargs", ): shell_io.check_convert_qresources(qr) diff --git a/tests/io/test_slurm.py b/tests/io/test_slurm.py index a87ab36..151370a 100644 --- a/tests/io/test_slurm.py +++ b/tests/io/test_slurm.py @@ -208,7 +208,7 @@ def test_check_convert_qresources(self, slurm_io): threads_per_process=2, gpus_per_job=4, email_address="john.doe@submit.qtk", - qkwargs={"tata": "toto", "titi": "tutu"}, + scheduler_kwargs={"tata": "toto", "titi": "tutu"}, ) header_dict = slurm_io.check_convert_qresources(resources=res) assert header_dict == {