Compare commits

...

3 commits
v1.1 ... main

9 changed files with 34 additions and 14 deletions

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "glicid-spawner"
version = "1.1"
version = "1.2"
description = "JupyterHub Batch Spawner for GLiCID"
authors = ["Benoit Seignovert <benoit.seignovert@univ-nantes.fr>"]
license = "BSD 3-Clause License"
@ -90,7 +90,7 @@ exclude_lines = [
]
[tool.tbump.version]
current = "1.1"
current = "1.2"
regex = '(?P<major>\d+)\.(?P<patch>\d+)'
[tool.tbump.git]

View file

@ -9,6 +9,7 @@ GLOBAL_USER = 'operator'
MAMBA_ROOT_PREFIX = f'{MICROMAMBA_ROOT}/{GLOBAL_USER}'
MAMBA_EXE = f'{MAMBA_ROOT_PREFIX}/bin/micromamba'
MAMBA_USER_BASE = f'{MICROMAMBA_ROOT}/$USER'
@dataclass

View file

@ -69,7 +69,7 @@ class SlurmNode:
self.state = state.strip().lower()
self.cpu = SlurmCpu(*re.findall(r'(\d+)/(\d+)/\d+/(\d+)', cpus_state)[0])
self.mem = int(memory_mb) // 1000 # in GB
self.gpu = SlurmGpu(*re.findall(r'gpu:(\w+):(\d+)', gres)[0] if 'gpu:' in gres else [])
self.gpu = SlurmGpu(*re.findall(r'gpu:([\w\.]+):(\d+)', gres)[0] if 'gpu:' in gres else [])
def __str__(self):
return self.hostname

View file

@ -9,7 +9,7 @@ from batchspawner import JobStatus, SlurmSpawner
from traitlets import Bool, Integer, Unicode, default
from .form import options_form, options_from_form
from .micromamba import MAMBA_EXE, MAMBA_ROOT_PREFIX
from .micromamba import MAMBA_EXE, MAMBA_ROOT_PREFIX, MAMBA_USER_BASE
from .progress import ElapseTime, get_progress
from .templates import get_template_src
@ -24,14 +24,19 @@ class GlicidSpawner(SlurmSpawner):
help='Spawner singleuser command.',
).tag(config=True)
req_mamba_exe = Unicode(
MAMBA_EXE,
help='Micromamba global exe',
).tag(config=True)
req_mamba_root_prefix = Unicode(
MAMBA_ROOT_PREFIX,
help='Micromamba global root prefix',
).tag(config=True)
req_mamba_exe = Unicode(
MAMBA_EXE,
help='Micromamba global exe',
req_mamba_user_base = Unicode(
MAMBA_USER_BASE,
help='Micromamba user base prefix',
).tag(config=True)
req_job_name = Unicode(

View file

@ -33,6 +33,7 @@ echo "The {{job_name}} logs are located in: ${JUPYTER_LOG_DIR}"
{# Micromamba config -#}
export MAMBA_EXE={{mamba_exe}};
export MAMBA_ROOT_PREFIX={{mamba_root_prefix}};
export PYTHONUSERBASE={{ mamba_user_base }};
source $MAMBA_ROOT_PREFIX/etc/profile.d/micromamba.sh;
{# Activate micromamba env requested by the user -#}

View file

@ -41,7 +41,7 @@
data-max-duration="{{max_duration}}"
{%- if loop.first %} checked{% endif %}>
<label for="gpu_{{gpu}}" class="btn btn-default btn-block">
{{ gpu }}
{{ gpu | replace("_"," ") | replace("."," ") | replace("gb","GB") }}
</label>
</div>
{% endfor -%}

View file

@ -9,13 +9,13 @@ nautilus standard cnode001 completing
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)
nautilus gpu gnode2 idle 0/96/0/96 256000 gpu:A100:2(S:0-1)
nautilus gpu gnode3 allocated 96/0/0/96 128000 gpu:A100:4(S:0-1)
nautilus gpu gnode3 allocated 96/0/0/96 128000 gpu:A100_2g.10gb:6(S
nautilus visu visu1 idle 0/96/0/96 768000 (null)
nautilus all cnode001 completing 0/96/0/96 384000 (null)
nautilus all cnode002 planned 0/96/0/96 768000 (null)
nautilus all gnode1 mixed 4/92/0/96 768000 gpu:A100:1(S:0-1)
nautilus all gnode2 idle 0/96/0/96 256000 gpu:A100:2(S:0-1)
nautilus all gnode3 allocated 96/0/0/96 128000 gpu:A100:4(S:0-1)
nautilus all gnode3 allocated 96/0/0/96 128000 gpu:A100_2g.10gb:6(S
nautilus all visu1 idle 0/96/0/96 768000 (null)
waves standard cribbar001 mixed 30/10/0/40 16000 (null)
waves gpu budbud006 allocated 64/0/0/64 256000 gpu:a100:2,mps:a100:

View file

@ -161,9 +161,17 @@ def test_slurm_sinfo_reader():
'P100',
'K80',
'P100',
] + 8 * ['A100']
'A100',
'A100',
'A100_2g.10gb',
'A100',
'A100',
'A100_2g.10gb',
'A100',
'A100',
]
assert [node.gpu.nb for node in nodes if node.gpu] == [2, 2, 2, 4, 1, 1, 2, 4, 1, 2, 4, 2, 2]
assert [node.gpu.nb for node in nodes if node.gpu] == [2, 2, 2, 4, 1, 1, 2, 6, 1, 2, 6, 2, 2]
def test_slurm_sinfo_filter(monkeypatch):
@ -253,4 +261,4 @@ def test_slurm_gres():
gpus = gres(resources)
# Sorted and without duplicates
assert gpus == ['A100', 'A40', 'None', 'P100', 'T4']
assert gpus == ['A100', 'A100_2g.10gb', 'A40', 'None', 'P100', 'T4']

View file

@ -27,8 +27,9 @@ def test_spawner_config():
assert 'bin/glicid-spawner-singleuser' in cmd
assert 'bin/jupyterhub-singleuser' in cmd
assert spawner.req_mamba_root_prefix == '/micromamba/operator'
assert spawner.req_mamba_exe == '/micromamba/operator/bin/micromamba'
assert spawner.req_mamba_root_prefix == '/micromamba/operator'
assert spawner.req_mamba_user_base == '/micromamba/$USER'
assert spawner.req_job_name == 'jupyterhub_glicid'
assert spawner.req_qos == 'short'
@ -70,8 +71,12 @@ def test_spawner_batch_script(monkeypatch):
assert 'export MAMBA_EXE=/micromamba/operator/bin/micromamba;' in script
assert 'export MAMBA_ROOT_PREFIX=/micromamba/operator;' in script
assert 'export PYTHONUSERBASE=/micromamba/$USER;' in script
assert 'micromamba activate /micromamba/john-doe/envs/foo;' in script
assert 'micromamba activate /micromamba/john-doe/envs/foo;' in script
assert 'export JUPYTER_PATH=/micromamba/john-doe/envs/foo/share/jupyter;' in script
assert re.search(r'.*/bin/glicid-spawner-singleuser .*/bin/jupyterhub-singleuser', script)