diff --git a/src/glicid_spawner/spawner.py b/src/glicid_spawner/spawner.py index d6aea5f..2231a1a 100644 --- a/src/glicid_spawner/spawner.py +++ b/src/glicid_spawner/spawner.py @@ -4,7 +4,7 @@ import asyncio import re from batchspawner import JobStatus, SlurmSpawner -from traitlets import Integer, Unicode, default +from traitlets import Bool, Integer, Unicode, default from .form import options_form, options_from_form from .progress import ElapseTime, get_progress @@ -13,6 +13,21 @@ from .progress import ElapseTime, get_progress class GlicidSpawner(SlurmSpawner): """Glicid SLURM Spawner.""" + disable_user_config = Bool( + True, + help='Disable per-user configuration of single-user servers.', + ).tag(config=True) + + notebook_dir = Unicode( + '/', + help='Path to the notebook directory for the single-user server.', + ).tag(config=True) + + @default('default_url') + def _default_url_default(self) -> str: + """The URL the single-user server should start in.""" + return '/tree' + self.user_options.get('workdir', '/home/{username}') + batchspawner_singleuser_cmd = Unicode( 'glicid-spawner-singleuser', help='Spawner singleuser command.', diff --git a/tests/test_spawner.py b/tests/test_spawner.py index ba0ceaf..ea4fb87 100644 --- a/tests/test_spawner.py +++ b/tests/test_spawner.py @@ -21,6 +21,9 @@ def test_spawner_config(): assert spawner.batchspawner_singleuser_cmd == 'glicid-spawner-singleuser' + assert spawner.disable_user_config + assert spawner.notebook_dir == '/' + assert spawner.default_url == '/tree/home/{username}' assert spawner.req_job_name == 'jupyterhub_glicid' assert spawner.req_qos == 'short' assert spawner.progress_rate == 10 @@ -53,6 +56,10 @@ def test_spawner_options_form(monkeypatch): assert spawner.options_form == "options_form('john-doe')" assert spawner.options_from_form({'foo': 123}) == "options_from_form({'foo': 123})" + spawner = GlicidSpawner(user_options={'workdir': '/LAB-DATA'}) + + assert spawner.default_url == '/tree/LAB-DATA' + @pytest.mark.asyncio async def test_spawner_progress(monkeypatch):