Reformat spawner resources entities
This commit is contained in:
parent
05be86da07
commit
b8efa00a05
2 changed files with 52 additions and 48 deletions
|
@ -1,24 +1,24 @@
|
|||
"""Test resources module."""
|
||||
|
||||
from glicid_spawner.resources import CPU, GPU, RAM
|
||||
from glicid_spawner.resources import CPU, GPU_DEFAULTS, MEMORY, gpu_max_duration
|
||||
|
||||
|
||||
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
|
||||
def test_default_resources():
|
||||
"""Test default resources duration default allocations."""
|
||||
assert list(CPU) == [1, 2, 4, 8, 12, 24]
|
||||
assert list(CPU.values()) == [24, 12, 6, 3, 2, 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 list(MEMORY) == [4, 8, 16, 32, 48, 96]
|
||||
assert list(MEMORY.values()) == [24, 12, 6, 3, 2, 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
|
||||
assert list(GPU_DEFAULTS) == ['None', 'A40', 'A100']
|
||||
assert list(GPU_DEFAULTS.values()) == [24, 2, 1]
|
||||
|
||||
|
||||
def test_gpu_max_duration():
|
||||
"""Test GPU max duration allocation."""
|
||||
gpu = gpu_max_duration(['T4', 'A100', 'None', 'K80', 'A100', 'T4'], unknown_default=3)
|
||||
|
||||
# Sorted by defaults order, then unknowns
|
||||
assert list(gpu) == ['None', 'A100', 'T4', 'K80']
|
||||
assert list(gpu.values()) == [24, 1, 3, 3]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue