mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Allow configuring default notebook interface from config.yaml
Also fix bug in how overrides were being done in config.yaml
This commit is contained in:
@@ -26,20 +26,25 @@ default = {
|
|||||||
'limits': {
|
'limits': {
|
||||||
'memory': '1G',
|
'memory': '1G',
|
||||||
'cpu': None
|
'cpu': None
|
||||||
|
},
|
||||||
|
'userEnvironment': {
|
||||||
|
'defaultApp': 'classic'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def apply_yaml_config(path, c):
|
def apply_yaml_config(path, c):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
tljh_config = _merge_dictionaries(yaml.safe_load(f), default)
|
tljh_config = _merge_dictionaries(default, yaml.safe_load(f))
|
||||||
else:
|
else:
|
||||||
tljh_config = copy.deepcopy(default)
|
tljh_config = copy.deepcopy(default)
|
||||||
|
|
||||||
update_auth(c, tljh_config)
|
update_auth(c, tljh_config)
|
||||||
update_userlists(c, tljh_config)
|
update_userlists(c, tljh_config)
|
||||||
update_limits(c, tljh_config)
|
update_limits(c, tljh_config)
|
||||||
|
update_user_environment(c, tljh_config)
|
||||||
|
|
||||||
|
|
||||||
def update_auth(c, config):
|
def update_auth(c, config):
|
||||||
@@ -77,6 +82,19 @@ def update_limits(c, config):
|
|||||||
c.SystemdSpawner.cpu_limit = limits['cpu']
|
c.SystemdSpawner.cpu_limit = limits['cpu']
|
||||||
|
|
||||||
|
|
||||||
|
def update_user_environment(c, config):
|
||||||
|
"""
|
||||||
|
Set user environment configuration
|
||||||
|
"""
|
||||||
|
user_env = config['userEnvironment']
|
||||||
|
|
||||||
|
# Set default application users are launched into
|
||||||
|
if user_env['defaultApp'] == 'jupyterlab':
|
||||||
|
c.Spawner.default_url = '/lab'
|
||||||
|
elif user_env['defaultApp'] == 'nteract':
|
||||||
|
c.Spawner.default_url = '/nteract'
|
||||||
|
|
||||||
|
|
||||||
def _merge_dictionaries(a, b, path=None, update=True):
|
def _merge_dictionaries(a, b, path=None, update=True):
|
||||||
"""
|
"""
|
||||||
Merge two dictionaries recursively.
|
Merge two dictionaries recursively.
|
||||||
|
|||||||
Reference in New Issue
Block a user