mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Add the jupyterhub-configurator service
This commit is contained in:
@@ -5,5 +5,3 @@ setup(
|
|||||||
entry_points={"tljh": ["simplest = tljh_simplest"]},
|
entry_points={"tljh": ["simplest = tljh_simplest"]},
|
||||||
py_modules=["tljh_simplest"],
|
py_modules=["tljh_simplest"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
8
setup.py
8
setup.py
@@ -18,11 +18,15 @@ setup(
|
|||||||
'backoff',
|
'backoff',
|
||||||
'requests',
|
'requests',
|
||||||
'bcrypt',
|
'bcrypt',
|
||||||
'jupyterhub-traefik-proxy==0.2.*'
|
'jupyterhub-traefik-proxy==0.2.*',
|
||||||
|
'jupyterhub-configurator @ git+https://github.com/yuvipanda/jupyterhub-configurator@ecca97e016e9a939dd48c6c0e66c40e4e2951fa7',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
'jupyterhub_configurator': [
|
||||||
|
'schema = tljh.schemas.tljh_configurator',
|
||||||
|
],
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
'tljh-config = tljh.config:main',
|
'tljh-config = tljh.config:main',
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ default = {
|
|||||||
'concurrency': 5,
|
'concurrency': 5,
|
||||||
'users': False,
|
'users': False,
|
||||||
'max_age': 0
|
'max_age': 0
|
||||||
|
},
|
||||||
|
'configurator': {
|
||||||
|
'enabled': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +178,8 @@ def update_userlists(c, config):
|
|||||||
"""
|
"""
|
||||||
users = config['users']
|
users = config['users']
|
||||||
|
|
||||||
c.Authenticator.whitelist = set(users['allowed'])
|
c.Authenticator.allowed_users = set(users['allowed'])
|
||||||
c.Authenticator.blacklist = set(users['banned'])
|
c.Authenticator.blocked_users = set(users['banned'])
|
||||||
c.Authenticator.admin_users = set(users['admin'])
|
c.Authenticator.admin_users = set(users['admin'])
|
||||||
|
|
||||||
|
|
||||||
@@ -249,10 +252,31 @@ def set_cull_idle_service(config):
|
|||||||
return cull_service
|
return cull_service
|
||||||
|
|
||||||
|
|
||||||
|
def set_configurator(config):
|
||||||
|
"""
|
||||||
|
Set the JupyterHub Configurator service
|
||||||
|
"""
|
||||||
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
configurator_cmd = [
|
||||||
|
sys.executable, "-m", "jupyterhub_configurator.app",
|
||||||
|
f"--Configurator.config_file={HERE}/jupyterhub_configurator_config.py"
|
||||||
|
]
|
||||||
|
configurator_service = {
|
||||||
|
'name': 'configurator',
|
||||||
|
'url': 'http://127.0.0.1:10101',
|
||||||
|
'command': configurator_cmd,
|
||||||
|
}
|
||||||
|
|
||||||
|
return configurator_service
|
||||||
|
|
||||||
|
|
||||||
def update_services(c, config):
|
def update_services(c, config):
|
||||||
c.JupyterHub.services = []
|
c.JupyterHub.services = []
|
||||||
|
|
||||||
if config['services']['cull']['enabled']:
|
if config['services']['cull']['enabled']:
|
||||||
c.JupyterHub.services.append(set_cull_idle_service(config))
|
c.JupyterHub.services.append(set_cull_idle_service(config))
|
||||||
|
if config['services']['configurator']['enabled']:
|
||||||
|
c.JupyterHub.services.append(set_configurator(config))
|
||||||
|
|
||||||
|
|
||||||
def _merge_dictionaries(a, b, path=None, update=True):
|
def _merge_dictionaries(a, b, path=None, update=True):
|
||||||
|
|||||||
0
tljh/schemas/__init__.py
Normal file
0
tljh/schemas/__init__.py
Normal file
27
tljh/schemas/tljh_configurator.py
Normal file
27
tljh/schemas/tljh_configurator.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from jupyterhub_configurator.hooks import hookimpl
|
||||||
|
|
||||||
|
@hookimpl
|
||||||
|
def jupyterhub_configurator_fields():
|
||||||
|
return {
|
||||||
|
"schema.default_interface": {
|
||||||
|
"type": "string",
|
||||||
|
"traitlet": "Spawner.default_url",
|
||||||
|
"title": "Default User Interface",
|
||||||
|
"enum": ["/tree", "/lab", "/nteract"],
|
||||||
|
"default": "/tree",
|
||||||
|
"enumMetadata": {
|
||||||
|
"/tree": {
|
||||||
|
"title": "Classic Notebook",
|
||||||
|
"description": "The original single-document interface for creating Jupyter Notebooks.",
|
||||||
|
},
|
||||||
|
"/lab": {
|
||||||
|
"title": "JupyterLab",
|
||||||
|
"description": "A Powerful next generation notebook interface",
|
||||||
|
},
|
||||||
|
"/nteract": {
|
||||||
|
"title": "Nteract",
|
||||||
|
"description": "Nteract notebook interface",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,9 @@ from tljh.normalize import generate_system_username
|
|||||||
from tljh import user
|
from tljh import user
|
||||||
from systemdspawner import SystemdSpawner
|
from systemdspawner import SystemdSpawner
|
||||||
from traitlets import Dict, Unicode, List
|
from traitlets import Dict, Unicode, List
|
||||||
|
from jupyterhub_configurator.mixins import ConfiguratorSpawnerMixin
|
||||||
|
|
||||||
class UserCreatingSpawner(SystemdSpawner):
|
class UserCreatingSpawner(ConfiguratorSpawnerMixin, SystemdSpawner):
|
||||||
"""
|
"""
|
||||||
SystemdSpawner with user creation on spawn.
|
SystemdSpawner with user creation on spawn.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user