From 78c9be32abcc9e82d97c2b805b2c286e6c22fe2e Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Fri, 29 Jun 2018 00:47:08 -0700 Subject: [PATCH] Allow configuring default notebook interface from config.yaml Also fix bug in how overrides were being done in config.yaml --- tljh/configurer.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tljh/configurer.py b/tljh/configurer.py index ba88a63..c16cad4 100644 --- a/tljh/configurer.py +++ b/tljh/configurer.py @@ -26,20 +26,25 @@ default = { 'limits': { 'memory': '1G', 'cpu': None + }, + 'userEnvironment': { + 'defaultApp': 'classic' } + } def apply_yaml_config(path, c): if os.path.exists(path): with open(path) as f: - tljh_config = _merge_dictionaries(yaml.safe_load(f), default) + tljh_config = _merge_dictionaries(default, yaml.safe_load(f)) else: tljh_config = copy.deepcopy(default) update_auth(c, tljh_config) update_userlists(c, tljh_config) update_limits(c, tljh_config) + update_user_environment(c, tljh_config) def update_auth(c, config): @@ -77,6 +82,19 @@ def update_limits(c, config): 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): """ Merge two dictionaries recursively.