Add dummy spawner config
This commit is contained in:
parent
93900c3875
commit
1cd88f3ef8
3 changed files with 59 additions and 1 deletions
|
@ -8,6 +8,9 @@ readme = "README.md"
|
||||||
repository = "https://gitlab.univ-nantes.fr/glicid/jupyter/spawner"
|
repository = "https://gitlab.univ-nantes.fr/glicid/jupyter/spawner"
|
||||||
packages = [{ include = "glicid_spawner", from = "src"}]
|
packages = [{ include = "glicid_spawner", from = "src"}]
|
||||||
|
|
||||||
|
[tool.poetry.plugins."jupyterhub.spawners"]
|
||||||
|
glicid-spawner = 'glicid_spawner:GlicidSpawner'
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
jupyterhub = "^4.0"
|
jupyterhub = "^4.0"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
from importlib.metadata import version
|
from importlib.metadata import version
|
||||||
|
|
||||||
__all__ = []
|
from .spawner import GlicidSpawner
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'GlicidSpawner',
|
||||||
|
]
|
||||||
|
|
||||||
__version__ = version('glicid-spawner')
|
__version__ = version('glicid-spawner')
|
||||||
|
|
51
src/glicid_spawner/spawner.py
Normal file
51
src/glicid_spawner/spawner.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
"""GLiCID spawner module."""
|
||||||
|
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
from batchspawner import SlurmSpawner
|
||||||
|
|
||||||
|
|
||||||
|
class GlicidSpawner(SlurmSpawner):
|
||||||
|
"""Glicid SLURM Spawner."""
|
||||||
|
|
||||||
|
def _options_form_default(self):
|
||||||
|
default_env = f'YOURNAME={self.user.name}\n'
|
||||||
|
return f"""
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="args">Extra notebook CLI arguments</label>
|
||||||
|
<input name="args" class="form-control"
|
||||||
|
placeholder="e.g. --debug"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="env">Environment variables (one per line)</label>
|
||||||
|
<textarea class="form-control" name="env">{default_env}</textarea>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
|
||||||
|
def options_from_form(self, formdata):
|
||||||
|
options = {}
|
||||||
|
options['env'] = env = {}
|
||||||
|
|
||||||
|
env_lines = formdata.get('env', [''])
|
||||||
|
for line in env_lines[0].splitlines():
|
||||||
|
if line:
|
||||||
|
key, value = line.split('=', 1)
|
||||||
|
env[key.strip()] = value.strip()
|
||||||
|
|
||||||
|
arg_s = formdata.get('args', [''])[0].strip()
|
||||||
|
if arg_s:
|
||||||
|
options['argv'] = shlex.split(arg_s)
|
||||||
|
return options
|
||||||
|
|
||||||
|
def get_args(self):
|
||||||
|
"""Return arguments to pass to the notebook server"""
|
||||||
|
argv = super().get_args()
|
||||||
|
if self.user_options.get('argv'):
|
||||||
|
argv.extend(self.user_options['argv'])
|
||||||
|
return argv
|
||||||
|
|
||||||
|
def get_env(self):
|
||||||
|
env = super().get_env()
|
||||||
|
if self.user_options.get('env'):
|
||||||
|
env.update(self.user_options['env'])
|
||||||
|
return env
|
Loading…
Add table
Reference in a new issue