From 882e51d5fac7270a055e82ad4407dfafa893922b Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 1 Dec 2023 15:48:42 -0500 Subject: [PATCH] Deal with case where `sinfo` (partitions) do not include the number of cores --- adaptive_scheduler/_scheduler/slurm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adaptive_scheduler/_scheduler/slurm.py b/adaptive_scheduler/_scheduler/slurm.py index 16dfd639..4ce37b3d 100644 --- a/adaptive_scheduler/_scheduler/slurm.py +++ b/adaptive_scheduler/_scheduler/slurm.py @@ -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 return int(numbers[0]) @@ -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"],