Enforce cluster flag in sinfo query
This commit is contained in:
parent
c0e95c4f55
commit
aaf16ee89d
6 changed files with 26 additions and 24 deletions
|
@ -32,7 +32,7 @@ SINFO = sinfo_from_file(
|
|||
)
|
||||
|
||||
# Single vs. multi-cluster implementation
|
||||
SLURM_SINGLE_CLUSTER = {'N/A': SINFO.pop('N/A')}
|
||||
SLURM_SINGLE_CLUSTER = {'cluster': SINFO.pop('cluster')}
|
||||
SLURM_MULTI_CLUSTER = SINFO
|
||||
GPU_SINGLE_CLUSTER = gpu_max_duration(gres(SLURM_SINGLE_CLUSTER))
|
||||
GPU_MULTI_CLUSTER = gpu_max_duration(gres(SLURM_MULTI_CLUSTER))
|
||||
|
|
|
@ -141,7 +141,7 @@ class SlurmCluster:
|
|||
|
||||
def sinfo_run(username: str = None) -> str:
|
||||
"""SLURM SINFO run command."""
|
||||
flags = '--federation --noheader --responding'
|
||||
flags = '--federation --noheader --responding --cluster=all'
|
||||
fmt = 'Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
|
||||
cmd = f'sinfo {flags} --Format={fmt}'
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div id="cluster-config-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading">
|
||||
<div class="panel-body">
|
||||
|
||||
{% if 'N/A' not in sinfo %}
|
||||
{% if 'cluster' not in sinfo %}
|
||||
<div class="form-group clusters">
|
||||
<label for="cluster" class="col-sm-3 control-label">Cluster:</label>
|
||||
<div class="col-sm-9 flex-container">
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
N/A Devel nazare001 idle 0/20/0/20 128000 (null)
|
||||
N/A GPU-short budbud001 mixed 20/20/0/40 184000 gpu:t4:2,mps:t4:2000
|
||||
N/A A40-short budbud002 allocated 40/0/0/40 184000 gpu:a40:2,mps:a40:20
|
||||
N/A AMD-short cloudbreak001 drained 0/0/32/32 128000 (null)
|
||||
N/A lowp budbud003 down~ 0/0/40/40 128000 gpu:p100:2
|
||||
N/A lowp budbud004 drained~ 0/0/20/20 128000 gpu:k80:4
|
||||
N/A lowp budbud005 idle~ 0/20/0/20 192000 gpu:p100:1
|
||||
cluster Devel nazare001 idle 0/20/0/20 128000 (null)
|
||||
cluster GPU-short budbud001 mixed 20/20/0/40 184000 gpu:t4:2,mps:t4:2000
|
||||
cluster A40-short budbud002 allocated 40/0/0/40 184000 gpu:a40:2,mps:a40:20
|
||||
cluster AMD-short cloudbreak001 drained 0/0/32/32 128000 (null)
|
||||
cluster lowp budbud003 down~ 0/0/40/40 128000 gpu:p100:2
|
||||
cluster lowp budbud004 drained~ 0/0/20/20 128000 gpu:k80:4
|
||||
cluster lowp budbud005 idle~ 0/20/0/20 192000 gpu:p100:1
|
||||
nautilus standard cnode001 completing 0/96/0/96 384000 (null)
|
||||
nautilus bigmem cnode002 planned 0/96/0/96 768000 (null)
|
||||
nautilus gpu gnode1 mixed 4/92/0/96 768000 gpu:A100:1(S:0-1)
|
||||
|
|
|
@ -12,7 +12,7 @@ from pytest import fixture
|
|||
DATA = Path(__file__).parent / 'data'
|
||||
SINFO = sinfo_from_file(DATA / 'sinfo.txt')
|
||||
|
||||
SLURM_SINGLE_CLUSTER = {'N/A': SINFO.pop('N/A')}
|
||||
SLURM_SINGLE_CLUSTER = {'cluster': SINFO.pop('cluster')}
|
||||
SLURM_MULTI_CLUSTER = SINFO
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ def test_options_attrs(mock_cluster):
|
|||
# Multi cluster configuration (default)
|
||||
sinfo = options['sinfo']
|
||||
|
||||
assert 'N/A' not in sinfo
|
||||
assert 'cluster' not in sinfo
|
||||
assert 'nautilus' in sinfo
|
||||
assert 'waves' in sinfo
|
||||
|
||||
|
@ -99,11 +99,11 @@ def test_options_attrs_single_cluster(mock_single_cluster):
|
|||
# Single cluster configuration
|
||||
sinfo = options['sinfo']
|
||||
|
||||
assert 'N/A' in sinfo
|
||||
assert 'cluster' in sinfo
|
||||
assert 'nautilus' not in sinfo
|
||||
assert 'waves' not in sinfo
|
||||
|
||||
node = sinfo['N/A']['Devel']['nazare001']
|
||||
node = sinfo['cluster']['Devel']['nazare001']
|
||||
|
||||
assert node == 'nazare001'
|
||||
assert node.cpu.idle == 20
|
||||
|
@ -218,32 +218,32 @@ def test_options_form_slurm_single_cluster(mock_single_cluster):
|
|||
|
||||
assert (
|
||||
'<div class="flex-item-4 slurm-partition" '
|
||||
'data-cluster="N/A" data-partition="GPU-short" '
|
||||
'data-cluster="cluster" data-partition="GPU-short" '
|
||||
'data-cpu="20" data-mem="184" data-gpu="T4">' in html
|
||||
)
|
||||
|
||||
assert (
|
||||
'<input type="radio" name="partition" id="partition_N/A_GPU-short" value="GPU-short">'
|
||||
'<input type="radio" name="partition" id="partition_cluster_GPU-short" value="GPU-short">'
|
||||
in html
|
||||
)
|
||||
assert (
|
||||
'<label for="partition_N/A_GPU-short" class="btn btn-default btn-block"> Gpu-short </label>'
|
||||
'<label for="partition_cluster_GPU-short" class="btn btn-default btn-block"> Gpu-short </label>'
|
||||
in html
|
||||
)
|
||||
|
||||
# Nodes (hidden by default)
|
||||
assert (
|
||||
'<div class="flex-item-4 slurm-node" '
|
||||
'data-cluster="N/A" data-partition="GPU-short" data-node="budbud001" '
|
||||
'data-cluster="cluster" data-partition="GPU-short" data-node="budbud001" '
|
||||
'data-cpu="20" data-mem="184" data-gpu="T4">' in html
|
||||
)
|
||||
|
||||
assert (
|
||||
'<input type="radio" name="node" id="node_N/A_GPU-short_budbud001" value="budbud001">'
|
||||
'<input type="radio" name="node" id="node_cluster_GPU-short_budbud001" value="budbud001">'
|
||||
in html
|
||||
)
|
||||
assert (
|
||||
'<label for="node_N/A_GPU-short_budbud001" class="btn btn-default btn-block"> Budbud001 </label>'
|
||||
'<label for="node_cluster_GPU-short_budbud001" class="btn btn-default btn-block"> Budbud001 </label>'
|
||||
in html
|
||||
)
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ def test_slurm_sinfo_run(monkeypatch):
|
|||
'--federation '
|
||||
'--noheader '
|
||||
'--responding '
|
||||
'--cluster=all '
|
||||
'--Format=Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
|
||||
)
|
||||
|
||||
|
@ -114,6 +115,7 @@ def test_slurm_sinfo_run(monkeypatch):
|
|||
'--federation '
|
||||
'--noheader '
|
||||
'--responding '
|
||||
'--cluster=all '
|
||||
'--Format=Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
|
||||
)
|
||||
|
||||
|
@ -127,7 +129,7 @@ def test_slurm_sinfo_reader():
|
|||
|
||||
node = nodes[0]
|
||||
|
||||
assert node.cluster == 'N/A'
|
||||
assert node.cluster == 'cluster'
|
||||
assert node.partition == 'Devel'
|
||||
assert node.hostname == 'nazare001'
|
||||
assert node.state == 'idle'
|
||||
|
@ -136,7 +138,7 @@ def test_slurm_sinfo_reader():
|
|||
assert node.mem == 128
|
||||
assert not node.gpu
|
||||
|
||||
assert [node.cluster for node in nodes] == 7 * ['N/A'] + 12 * ['nautilus'] + 6 * ['waves']
|
||||
assert [node.cluster for node in nodes] == 7 * ['cluster'] + 12 * ['nautilus'] + 6 * ['waves']
|
||||
|
||||
assert len([node for node in nodes if node.state in ('idle', 'mixed')]) == 10
|
||||
|
||||
|
@ -172,7 +174,7 @@ def test_slurm_sinfo_filter(monkeypatch):
|
|||
|
||||
assert isinstance(clusters, dict)
|
||||
assert len(clusters) == 3
|
||||
assert list(clusters) == ['N/A', 'nautilus', 'waves'] # __eq__ on cluster.name
|
||||
assert list(clusters) == ['cluster', 'nautilus', 'waves'] # __eq__ on cluster.name
|
||||
|
||||
assert [len(partitions) for partitions in clusters.values()] == [2, 4, 2]
|
||||
|
||||
|
@ -195,7 +197,7 @@ def test_slurm_sinfo_filter(monkeypatch):
|
|||
# Get only `idle` nodes
|
||||
clusters = sinfo_filter(resources, with_states=('idle'))
|
||||
|
||||
assert list(clusters) == ['N/A', 'nautilus']
|
||||
assert list(clusters) == ['cluster', 'nautilus']
|
||||
assert [len(partitions) for partitions in clusters.values()] == [1, 3]
|
||||
|
||||
# Discard clusters without partition available
|
||||
|
|
Loading…
Add table
Reference in a new issue