Skip to content

Commit

Permalink
Deal with case where sinfo (partitions) do not include the number o…
Browse files Browse the repository at this point in the history
…f cores
  • Loading branch information
basnijholt committed Dec 1, 2023
1 parent 2084e27 commit 882e51d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adaptive_scheduler/_scheduler/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def partitions(self) -> dict[str, int]:

def _get_ncores(partition: str) -> int:
numbers = re.findall(r"\d+", partition)
if not numbers:
return None

Check warning on line 290 in adaptive_scheduler/_scheduler/slurm.py

View check run for this annotation

Codecov / codecov/patch

adaptive_scheduler/_scheduler/slurm.py#L290

Added line #L290 was not covered by tests
return int(numbers[0])


Expand All @@ -294,7 +296,7 @@ def slurm_partitions(
*,
timeout: int = 5,
with_ncores: bool = True,
) -> list[str] | dict[str, int]:
) -> list[str] | dict[str, int | None]:
"""Get the available slurm partitions, raises subprocess.TimeoutExpired after timeout."""
output = subprocess.run(
["sinfo", "-ahO", "partition"],
Expand Down

0 comments on commit 882e51d

Please sign in to comment.