Add resources tests
This commit is contained in:
parent
f00b406962
commit
bf8bce2fb1
4 changed files with 39 additions and 12 deletions
|
@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Resource:
|
class Resource:
|
||||||
"""Cluster generic resource."""
|
"""Generic cluster resource."""
|
||||||
|
|
||||||
description: str
|
description: str
|
||||||
max_duration: int
|
max_duration: int
|
||||||
|
@ -21,16 +21,15 @@ CPU = [
|
||||||
]
|
]
|
||||||
|
|
||||||
RAM = [
|
RAM = [
|
||||||
Resource('4', 24),
|
Resource('4 GB', 24),
|
||||||
Resource('8', 12),
|
Resource('8 GB', 12),
|
||||||
Resource('16', 6),
|
Resource('16 GB', 6),
|
||||||
Resource('32', 3),
|
Resource('32 GB', 3),
|
||||||
Resource('48', 2),
|
Resource('48 GB', 2),
|
||||||
Resource('96', 1),
|
Resource('96 GB', 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
GPU = [
|
GPU = [
|
||||||
Resource('no', 24),
|
Resource('No', 24),
|
||||||
Resource('A40', 2),
|
|
||||||
Resource('A100', 1),
|
Resource('A100', 1),
|
||||||
]
|
]
|
||||||
|
|
|
@ -74,7 +74,11 @@ def _sinfo_reader(result) -> list:
|
||||||
|
|
||||||
|
|
||||||
def sinfo(with_states=('idle', 'mixed')) -> dict:
|
def sinfo(with_states=('idle', 'mixed')) -> dict:
|
||||||
"""SLURM SINFO resources available with a given state(s)."""
|
"""SLURM SINFO resources available with a given state(s).
|
||||||
|
|
||||||
|
Grouped by cluster and partition names.
|
||||||
|
|
||||||
|
"""
|
||||||
resources = _sinfo_reader(_sinfo_run())
|
resources = _sinfo_reader(_sinfo_run())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<input type="radio" name="ram" id="ram_{{loop.index0}}" value="{{loop.index0}}"
|
<input type="radio" name="ram" id="ram_{{loop.index0}}" value="{{loop.index0}}"
|
||||||
data-max-duration="{{ram.max_duration}}" {%- if loop.first -%}checked{%- endif -%}>
|
data-max-duration="{{ram.max_duration}}" {%- if loop.first -%}checked{%- endif -%}>
|
||||||
<label for="ram_{{loop.index0}}" class="btn btn-default btn-block">
|
<label for="ram_{{loop.index0}}" class="btn btn-default btn-block">
|
||||||
{{ ram.description }} GB
|
{{ ram.description }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<input type="radio" name="gpu" id="gpu_{{loop.index0}}" value="{{loop.index0}}"
|
<input type="radio" name="gpu" id="gpu_{{loop.index0}}" value="{{loop.index0}}"
|
||||||
data-max-duration="{{gpu.max_duration}}" {%- if loop.first -%}checked{%- endif -%}>
|
data-max-duration="{{gpu.max_duration}}" {%- if loop.first -%}checked{%- endif -%}>
|
||||||
<label for="gpu_{{loop.index0}}" class="btn btn-default btn-block">
|
<label for="gpu_{{loop.index0}}" class="btn btn-default btn-block">
|
||||||
{{ gpu.description | capitalize }}
|
{{ gpu.description }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
|
24
tests/test_resources.py
Normal file
24
tests/test_resources.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""Test resources module."""
|
||||||
|
|
||||||
|
from glicid_spawner.resources import CPU, GPU, RAM
|
||||||
|
|
||||||
|
|
||||||
|
def test_glicid_default_resources():
|
||||||
|
"""Test GLiCID default resources."""
|
||||||
|
assert len(CPU) == 6
|
||||||
|
assert CPU[0].description == '1'
|
||||||
|
assert CPU[0].max_duration == 24
|
||||||
|
assert CPU[-1].description == '24'
|
||||||
|
assert CPU[-1].max_duration == 1
|
||||||
|
|
||||||
|
assert len(RAM) == 6
|
||||||
|
assert RAM[0].description == '4 GB'
|
||||||
|
assert RAM[0].max_duration == 24
|
||||||
|
assert RAM[-1].description == '96 GB'
|
||||||
|
assert RAM[-1].max_duration == 1
|
||||||
|
|
||||||
|
assert len(GPU) == 2
|
||||||
|
assert GPU[0].description == 'No'
|
||||||
|
assert GPU[0].max_duration == 24
|
||||||
|
assert GPU[-1].description == 'A100'
|
||||||
|
assert GPU[-1].max_duration == 1
|
Loading…
Add table
Reference in a new issue