Enforce GRES resources as lowercase for specific clusters

This commit is contained in:
Benoît Seignovert 2024-03-07 15:21:37 +01:00
parent a723a2376e
commit ae9ac12918
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
2 changed files with 12 additions and 3 deletions

View file

@ -11,6 +11,10 @@ TEMPLATES = Environment(
autoescape=select_autoescape(), autoescape=select_autoescape(),
) )
GRES_CLUSTERS_LOWERCASE = [
'waves',
]
def options_attrs(username: str) -> dict: def options_attrs(username: str) -> dict:
"""Form options attributes.""" """Form options attributes."""
@ -62,7 +66,10 @@ def options_from_form(formdata) -> dict:
} }
if gpu != 'None': if gpu != 'None':
options['gres'] = f'gpu:{gpu.lower()}' if cluster in GRES_CLUSTERS_LOWERCASE:
gpu = gpu.lower()
options['gres'] = f'gpu:{gpu}'
if cluster: if cluster:
options['cluster'] = cluster options['cluster'] = cluster

View file

@ -283,7 +283,7 @@ def test_options_from_form():
'nprocs': 2, 'nprocs': 2,
'memory': '16GB', 'memory': '16GB',
'runtime': '02:00:00', 'runtime': '02:00:00',
'gres': 'gpu:a40', 'gres': 'gpu:A40',
'cluster': 'nautilus', 'cluster': 'nautilus',
} }
@ -303,7 +303,7 @@ def test_options_from_form():
'nprocs': 8, 'nprocs': 8,
'memory': '16GB', 'memory': '16GB',
'runtime': '01:00:00', 'runtime': '01:00:00',
'gres': 'gpu:t4', 'gres': 'gpu:T4',
'partition': 'GPU-short', 'partition': 'GPU-short',
} }
@ -314,6 +314,7 @@ def test_options_from_form():
'cpu': ['128'], 'cpu': ['128'],
'mem': ['4096'], 'mem': ['4096'],
'gpu': ['A100'], 'gpu': ['A100'],
'cluster': ['waves'], # Gres should be lowercased for this cluster
'node': ['cribbar001'], 'node': ['cribbar001'],
} }
@ -324,5 +325,6 @@ def test_options_from_form():
'memory': '4096GB', 'memory': '4096GB',
'runtime': '00:00:00', 'runtime': '00:00:00',
'gres': 'gpu:a100', 'gres': 'gpu:a100',
'cluster': 'waves',
'node': 'cribbar001', 'node': 'cribbar001',
} }