From 84361f183e2f81eca957a04425cdaa77463f1685 Mon Sep 17 00:00:00 2001 From: Benoit Seignovert Date: Wed, 14 Feb 2024 18:46:53 +0100 Subject: [PATCH] Remove SLURM parsing of N/A cluster --- src/glicid_spawner/slurm.py | 2 +- tests/test_slurm.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/glicid_spawner/slurm.py b/src/glicid_spawner/slurm.py index e96eb8e..318b26d 100644 --- a/src/glicid_spawner/slurm.py +++ b/src/glicid_spawner/slurm.py @@ -51,7 +51,7 @@ class SlurmNode: gpu: SlurmGpu def __init__(self, cluster, partition, hostname, state, cpus_state, memory_mb, gres): # noqa: PLR0913 - self.cluster = None if 'N/A' in cluster else cluster.strip() + self.cluster = cluster.strip() self.partition = partition.strip() self.hostname = hostname.strip() self.state = state.strip().lower() diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 50ebfe0..8346080 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -80,7 +80,7 @@ def test_slurm_sinfo_reader(): node = nodes[0] - assert node.cluster is None + assert node.cluster == 'N/A' assert node.partition == 'Devel' assert node.hostname == 'nazare001' assert node.state == 'idle' @@ -89,7 +89,7 @@ def test_slurm_sinfo_reader(): assert node.mem == 128 assert not node.gpu - assert [node.cluster for node in nodes] == 7 * [None] + 6 * ['nautilus'] + 4 * ['waves'] + assert [node.cluster for node in nodes] == 7 * ['N/A'] + 6 * ['nautilus'] + 4 * ['waves'] assert len([node for node in nodes if node.state in ('idle', 'mixed')]) == 7 @@ -125,7 +125,7 @@ def test_slurm_sinfo_filter(monkeypatch): assert isinstance(clusters, dict) assert len(clusters) == 3 - assert list(clusters) == [None, 'nautilus', 'waves'] + assert list(clusters) == ['N/A', 'nautilus', 'waves'] assert [len(partitions) for partitions in clusters.values()] == [2, 2, 2] @@ -148,7 +148,7 @@ def test_slurm_sinfo_filter(monkeypatch): # Get only `idle` nodes clusters = sinfo_filter(resources, with_states=('idle')) - assert list(clusters) == [None, 'nautilus', 'waves'] + assert list(clusters) == ['N/A', 'nautilus', 'waves'] assert [len(partitions) for partitions in clusters.values()] == [1, 2, 1] # Discard clusters without partition available