def apply_mock_config(overrides): """ Configure a mock configurer with given overrides. overrides should be a dict that matches what you parse from a config.yaml """ c = MockConfigurer() configurer.apply_config(overrides, c) return c
user.ensure_user_group(system_username, 'jupyterhub-users') if self.user.admin: user.ensure_user_group(system_username, 'jupyterhub-admins') else: user.remove_user_group(system_username, 'jupyterhub-admins') return super().start() c.JupyterHub.spawner_class = CustomSpawner c.JupyterHub.port = 80 # Use a high port so users can try this on machines with a JupyterHub already present c.JupyterHub.hub_port = 15001 c.ConfigurableHTTPProxy.should_start = False c.ConfigurableHTTPProxy.api_url = 'http://127.0.0.1:15002' c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, 'bin')] c.SystemdSpawner.default_shell = '/bin/bash' # Drop the '-singleuser' suffix present in the default template c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}' config_overrides_path = os.path.join(INSTALL_PREFIX, 'config.yaml') if os.path.exists(config_overrides_path): with open(config_overrides_path) as f: config_overrides = yaml.safe_load(f) else: config_overrides = {} configurer.apply_config(config_overrides, c)
# Use a high port so users can try this on machines with a JupyterHub already present c.JupyterHub.hub_port = 15001 c.TraefikTomlProxy.should_start = False dynamic_conf_file_path = os.path.join(INSTALL_PREFIX, 'state', 'rules.toml') c.TraefikTomlProxy.toml_dynamic_config_file = dynamic_conf_file_path c.JupyterHub.proxy_class = TraefikTomlProxy c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, 'bin')] c.SystemdSpawner.default_shell = '/bin/bash' # Drop the '-singleuser' suffix present in the default template c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}' tljh_config = configurer.load_config() configurer.apply_config(tljh_config, c) # Let TLJH hooks modify `c` if they want # Set up plugin infrastructure pm = pluggy.PluginManager('tljh') pm.add_hookspecs(hooks) pm.load_setuptools_entrypoints('tljh') # Call our custom configuration plugin pm.hook.tljh_custom_jupyterhub_config(c=c) # Load arbitrary .py config files if they exist. # This is our escape hatch extra_configs = sorted( glob(os.path.join(CONFIG_DIR, 'jupyterhub_config.d', '*.py'))) for ec in extra_configs:
""" This file is only used for local development and overrides some of the default values from the plugin. """ import getpass from jupyterhub.auth import DummyAuthenticator from tljh.configurer import apply_config, load_config from tljh_repo2docker import tljh_custom_jupyterhub_config c.JupyterHub.services = [] # set default limits in the TLJH config in memory tljh_config = load_config() tljh_config["limits"]["memory"] = "2G" tljh_config["limits"]["cpu"] = 2 apply_config(tljh_config, c) tljh_custom_jupyterhub_config(c) c.JupyterHub.authenticator_class = DummyAuthenticator user = getpass.getuser() c.Authenticator.admin_users = {user, "alice"}