Add slurm cluster and partition len property
This commit is contained in:
parent
fc54701400
commit
4eef9d7016
2 changed files with 10 additions and 0 deletions
|
@ -79,6 +79,9 @@ class SlurmPartition:
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.nodes)
|
return iter(self.nodes)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.nodes)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gpus(self) -> str:
|
def gpus(self) -> str:
|
||||||
"""List of GPUs available."""
|
"""List of GPUs available."""
|
||||||
|
@ -108,6 +111,9 @@ class SlurmCluster:
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.partitions)
|
return iter(self.partitions)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.partitions)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return str(self) == str(other)
|
return str(self) == str(other)
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ def test_slurm_dataclasses():
|
||||||
assert str(partition) == 'standard' # = name
|
assert str(partition) == 'standard' # = name
|
||||||
assert partition.name == 'standard'
|
assert partition.name == 'standard'
|
||||||
|
|
||||||
|
assert len(partition) == 1
|
||||||
|
|
||||||
for _node in partition:
|
for _node in partition:
|
||||||
assert str(_node) == 'cnode001'
|
assert str(_node) == 'cnode001'
|
||||||
|
|
||||||
|
@ -87,6 +89,8 @@ def test_slurm_dataclasses():
|
||||||
assert cluster.name == 'nautilus'
|
assert cluster.name == 'nautilus'
|
||||||
assert cluster == 'nautilus' # __eq__
|
assert cluster == 'nautilus' # __eq__
|
||||||
|
|
||||||
|
assert len(cluster) == 1
|
||||||
|
|
||||||
for _partition in cluster:
|
for _partition in cluster:
|
||||||
assert str(_partition) == 'standard'
|
assert str(_partition) == 'standard'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue