Add slurm partition eq comparison

This commit is contained in:
Benoît Seignovert 2024-02-19 17:40:57 +01:00
parent 4eef9d7016
commit e8ae32cc86
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
2 changed files with 5 additions and 1 deletions

View file

@ -82,6 +82,9 @@ class SlurmPartition:
def __len__(self):
return len(self.nodes)
def __eq__(self, other):
return str(self) == str(other)
@property
def gpus(self) -> str:
"""List of GPUs available."""

View file

@ -72,6 +72,7 @@ def test_slurm_dataclasses():
assert str(partition) == 'standard' # = name
assert partition.name == 'standard'
assert partition == 'standard' # __eq__ on name
assert len(partition) == 1
@ -87,7 +88,7 @@ def test_slurm_dataclasses():
assert str(cluster) == 'nautilus' # = name
assert cluster.name == 'nautilus'
assert cluster == 'nautilus' # __eq__
assert cluster == 'nautilus' # __eq__ on name
assert len(cluster) == 1