Skip to content

Commit

Permalink
rename qkwargs to scheduler_kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Jan 29, 2024
1 parent 36295be commit 3c2ab3d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
11 changes: 5 additions & 6 deletions src/qtoolkit/core/data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions src/qtoolkit/io/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -457,6 +457,6 @@ def supported_qresources_keys(self) -> list:
"nodes",
"threads_per_process",
"email_address",
"qkwargs",
"scheduler_kwargs",
]
return supported
6 changes: 3 additions & 3 deletions src/qtoolkit/io/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -600,6 +600,6 @@ def supported_qresources_keys(self) -> list:
"threads_per_process",
"gpus_per_job",
"email_address",
"qkwargs",
"scheduler_kwargs",
]
return supported
2 changes: 1 addition & 1 deletion tests/core/test_data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions tests/io/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_check_convert_qresources(self, slurm_io):
threads_per_process=2,
gpus_per_job=4,
email_address="[email protected]",
qkwargs={"tata": "toto", "titi": "tutu"},
scheduler_kwargs={"tata": "toto", "titi": "tutu"},
)
header_dict = slurm_io.check_convert_qresources(resources=res)
assert header_dict == {
Expand Down

0 comments on commit 3c2ab3d

Please sign in to comment.