Add explicit path to spawner and singleuser commands
This commit is contained in:
parent
7792d567f5
commit
6af885f148
2 changed files with 28 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from batchspawner import JobStatus, SlurmSpawner
|
from batchspawner import JobStatus, SlurmSpawner
|
||||||
from traitlets import Bool, Integer, Unicode, default
|
from traitlets import Bool, Integer, Unicode, default
|
||||||
|
@ -11,6 +13,8 @@ from .micromamba import MAMBA_EXE, MAMBA_ROOT_PREFIX
|
||||||
from .progress import ElapseTime, get_progress
|
from .progress import ElapseTime, get_progress
|
||||||
from .templates import get_template_src
|
from .templates import get_template_src
|
||||||
|
|
||||||
|
SPAWNER_BIN = Path(sys.exec_prefix) / 'bin'
|
||||||
|
|
||||||
|
|
||||||
class GlicidSpawner(SlurmSpawner):
|
class GlicidSpawner(SlurmSpawner):
|
||||||
"""Glicid SLURM Spawner."""
|
"""Glicid SLURM Spawner."""
|
||||||
|
@ -60,6 +64,20 @@ class GlicidSpawner(SlurmSpawner):
|
||||||
"""The URL the single-user server should start in."""
|
"""The URL the single-user server should start in."""
|
||||||
return '/lab/tree' + self.user_options.get('workdir', '/home/{username}') + '?reset'
|
return '/lab/tree' + self.user_options.get('workdir', '/home/{username}') + '?reset'
|
||||||
|
|
||||||
|
def cmd_formatted_for_batch(self):
|
||||||
|
"""The command which is substituted inside of the batch script.
|
||||||
|
|
||||||
|
Here we need the absolute path to the spawner and singleuser commands.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return ' '.join(
|
||||||
|
[
|
||||||
|
str(SPAWNER_BIN / self.batchspawner_singleuser_cmd),
|
||||||
|
str(SPAWNER_BIN / self.cmd[0]),
|
||||||
|
*self.get_args(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
slurm_job_id_re = Unicode(r'(\d+)(?:;(\w+))?').tag(config=True)
|
slurm_job_id_re = Unicode(r'(\d+)(?:;(\w+))?').tag(config=True)
|
||||||
|
|
||||||
def parse_job_id(self, output):
|
def parse_job_id(self, output):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Test GLiCID spawner module."""
|
"""Test GLiCID spawner module."""
|
||||||
|
|
||||||
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
|
@ -22,6 +23,10 @@ def test_spawner_config():
|
||||||
|
|
||||||
assert spawner.batchspawner_singleuser_cmd == 'glicid-spawner-singleuser'
|
assert spawner.batchspawner_singleuser_cmd == 'glicid-spawner-singleuser'
|
||||||
|
|
||||||
|
cmd = spawner.cmd_formatted_for_batch()
|
||||||
|
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_root_prefix == '/micromamba/operator'
|
||||||
assert spawner.req_mamba_exe == '/micromamba/operator/bin/micromamba'
|
assert spawner.req_mamba_exe == '/micromamba/operator/bin/micromamba'
|
||||||
assert spawner.req_job_name == 'jupyterhub_glicid'
|
assert spawner.req_job_name == 'jupyterhub_glicid'
|
||||||
|
@ -49,7 +54,9 @@ def test_spawner_batch_script(monkeypatch):
|
||||||
)
|
)
|
||||||
|
|
||||||
script = format_template(
|
script = format_template(
|
||||||
spawner.batch_script, **(spawner.get_req_subvars() | spawner.user_options)
|
spawner.batch_script,
|
||||||
|
cmd=spawner.cmd_formatted_for_batch(),
|
||||||
|
**(spawner.get_req_subvars() | spawner.user_options),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert '#SBATCH --job-name=jupyterhub_glicid' in script
|
assert '#SBATCH --job-name=jupyterhub_glicid' in script
|
||||||
|
@ -65,6 +72,8 @@ def test_spawner_batch_script(monkeypatch):
|
||||||
assert 'export MAMBA_ROOT_PREFIX=/micromamba/operator;' in script
|
assert 'export MAMBA_ROOT_PREFIX=/micromamba/operator;' in script
|
||||||
assert 'micromamba activate /micromamba/john-doe/envs/foo;' in script
|
assert 'micromamba activate /micromamba/john-doe/envs/foo;' in script
|
||||||
|
|
||||||
|
assert re.search(r'.*/bin/glicid-spawner-singleuser .*/bin/jupyterhub-singleuser', script)
|
||||||
|
|
||||||
|
|
||||||
def test_spawner_parse_job_id():
|
def test_spawner_parse_job_id():
|
||||||
"""Test spawner job id parser."""
|
"""Test spawner job id parser."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue