Add working directory field in options form

This commit is contained in:
Benoît Seignovert 2024-02-26 14:35:30 +01:00
parent 0273f449b8
commit c67e8742c8
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
8 changed files with 71 additions and 8 deletions

View file

@ -48,6 +48,15 @@ def test_options_attrs(mock_cluster):
assert options['username'] == 'john-doe'
assert options['folders'] == [
'/home/john-doe',
'/scratch/nautilus/users/john-doe',
'/scratch/waves/users/john-doe',
'/scratch/nautilus/projects',
'/scratch/waves/projects',
'/LAB-DATA/',
]
assert [env.path for env in options['envs']] == [
'/john-doe/envs/foo',
'/john-doe/envs/bar',
@ -243,6 +252,7 @@ def test_options_from_form():
"""Test options from form parser."""
# No GPU
formdata = {
'workdir': ['/home/john-doe/'],
'python-env': ['/john-doe/envs/foo'],
'cpu': ['1'],
'mem': ['4'],
@ -250,6 +260,7 @@ def test_options_from_form():
}
assert options_from_form(formdata) == {
'workdir': '/home/john-doe/',
'pyenv': '/john-doe/envs/foo',
'nprocs': 1,
'memory': '4GB',
@ -258,6 +269,7 @@ def test_options_from_form():
# With GPU (in defaults list)
formdata = {
'workdir': ['/scratch/nautilus/users/john-doe/'],
'python-env': ['/john-doe/envs/bar'],
'cpu': ['2'],
'mem': ['16'],
@ -266,6 +278,7 @@ def test_options_from_form():
}
assert options_from_form(formdata) == {
'workdir': '/scratch/nautilus/users/john-doe/',
'pyenv': '/john-doe/envs/bar',
'nprocs': 2,
'memory': '16GB',
@ -276,6 +289,7 @@ def test_options_from_form():
# With unknown GPU (default 1h allocation)
formdata = {
'workdir': ['/scratch/waves/projects/'],
'python-env': ['/global/envs/baz'],
'cpu': ['8'],
'mem': ['16'],
@ -284,6 +298,7 @@ def test_options_from_form():
}
assert options_from_form(formdata) == {
'workdir': '/scratch/waves/projects/',
'pyenv': '/global/envs/baz',
'nprocs': 8,
'memory': '16GB',
@ -294,6 +309,7 @@ def test_options_from_form():
# Invalid CPU request (0h allocated)
formdata = {
'workdir': ['/LAD-DATA/'],
'python-env': ['/global/envs/qux'],
'cpu': ['128'],
'mem': ['4096'],
@ -302,6 +318,7 @@ def test_options_from_form():
}
assert options_from_form(formdata) == {
'workdir': '/LAD-DATA/',
'pyenv': '/global/envs/qux',
'nprocs': 128,
'memory': '4096GB',

View file

@ -1,6 +1,6 @@
"""Test resources module."""
from glicid_spawner.resources import CPU, GPU_DEFAULTS, MEMORY, gpu_max_duration
from glicid_spawner.resources import CPU, GPU_DEFAULTS, MEMORY, get_folders, gpu_max_duration
def test_default_resources():
@ -22,3 +22,15 @@ def test_gpu_max_duration():
# Sorted by defaults order, then unknowns
assert list(gpu) == ['None', 'A100', 'T4', 'K80']
assert list(gpu.values()) == [24, 1, 3, 3]
def test_resources_workdir():
"""Test resources working directories."""
assert get_folders('john-doe') == [
'/home/john-doe',
'/scratch/nautilus/users/john-doe',
'/scratch/waves/users/john-doe',
'/scratch/nautilus/projects',
'/scratch/waves/projects',
'/LAB-DATA/',
]