diff --git a/pyproject.toml b/pyproject.toml index 2f2f3ae..66f8f02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "glicid-spawner" -version = "1.2" +version = "1.1" description = "JupyterHub Batch Spawner for GLiCID" authors = ["Benoit Seignovert "] license = "BSD 3-Clause License" @@ -90,7 +90,7 @@ exclude_lines = [ ] [tool.tbump.version] -current = "1.2" +current = "1.1" regex = '(?P\d+)\.(?P\d+)' [tool.tbump.git] diff --git a/src/glicid_spawner/micromamba.py b/src/glicid_spawner/micromamba.py index 0fe1641..1d42063 100644 --- a/src/glicid_spawner/micromamba.py +++ b/src/glicid_spawner/micromamba.py @@ -9,7 +9,6 @@ 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 diff --git a/src/glicid_spawner/slurm.py b/src/glicid_spawner/slurm.py index 15da6fd..1aea52d 100644 --- a/src/glicid_spawner/slurm.py +++ b/src/glicid_spawner/slurm.py @@ -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 diff --git a/src/glicid_spawner/spawner.py b/src/glicid_spawner/spawner.py index b65af99..cdd7631 100644 --- a/src/glicid_spawner/spawner.py +++ b/src/glicid_spawner/spawner.py @@ -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, MAMBA_USER_BASE +from .micromamba import MAMBA_EXE, MAMBA_ROOT_PREFIX from .progress import ElapseTime, get_progress from .templates import get_template_src @@ -24,19 +24,14 @@ 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_user_base = Unicode( - MAMBA_USER_BASE, - help='Micromamba user base prefix', + req_mamba_exe = Unicode( + MAMBA_EXE, + help='Micromamba global exe', ).tag(config=True) req_job_name = Unicode( diff --git a/src/glicid_spawner/templates/slurm_script.jinja b/src/glicid_spawner/templates/slurm_script.jinja index c3e4515..3c01679 100644 --- a/src/glicid_spawner/templates/slurm_script.jinja +++ b/src/glicid_spawner/templates/slurm_script.jinja @@ -33,7 +33,6 @@ 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 -#} diff --git a/src/glicid_spawner/templates/views/resources.jinja b/src/glicid_spawner/templates/views/resources.jinja index d29de24..efae401 100644 --- a/src/glicid_spawner/templates/views/resources.jinja +++ b/src/glicid_spawner/templates/views/resources.jinja @@ -41,7 +41,7 @@ data-max-duration="{{max_duration}}" {%- if loop.first %} checked{% endif %}> {% endfor -%} diff --git a/tests/data/sinfo.txt b/tests/data/sinfo.txt index 8079789..37d0b25 100644 --- a/tests/data/sinfo.txt +++ b/tests/data/sinfo.txt @@ -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_2g.10gb:6(S +nautilus gpu gnode3 allocated 96/0/0/96 128000 gpu:A100:4(S:0-1) 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_2g.10gb:6(S +nautilus all gnode3 allocated 96/0/0/96 128000 gpu:A100:4(S:0-1) 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: diff --git a/tests/test_slurm.py b/tests/test_slurm.py index c38829d..a4d8693 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -161,17 +161,9 @@ def test_slurm_sinfo_reader(): 'P100', 'K80', 'P100', - 'A100', - 'A100', - 'A100_2g.10gb', - 'A100', - 'A100', - 'A100_2g.10gb', - 'A100', - 'A100', - ] + ] + 8 * ['A100'] - assert [node.gpu.nb for node in nodes if node.gpu] == [2, 2, 2, 4, 1, 1, 2, 6, 1, 2, 6, 2, 2] + assert [node.gpu.nb for node in nodes if node.gpu] == [2, 2, 2, 4, 1, 1, 2, 4, 1, 2, 4, 2, 2] def test_slurm_sinfo_filter(monkeypatch): @@ -261,4 +253,4 @@ def test_slurm_gres(): gpus = gres(resources) # Sorted and without duplicates - assert gpus == ['A100', 'A100_2g.10gb', 'A40', 'None', 'P100', 'T4'] + assert gpus == ['A100', 'A40', 'None', 'P100', 'T4'] diff --git a/tests/test_spawner.py b/tests/test_spawner.py index 7990185..8ac208b 100644 --- a/tests/test_spawner.py +++ b/tests/test_spawner.py @@ -27,9 +27,8 @@ def test_spawner_config(): assert 'bin/glicid-spawner-singleuser' in cmd assert 'bin/jupyterhub-singleuser' in cmd - 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_mamba_exe == '/micromamba/operator/bin/micromamba' assert spawner.req_job_name == 'jupyterhub_glicid' assert spawner.req_qos == 'short' @@ -71,12 +70,8 @@ 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)