From 653740cbad7ce0c8a8752ce83e4d3c2c754b13cb Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 10 Mar 2022 16:35:10 +0100 Subject: [PATCH] Re-use ServerApp.config_file_paths for consistency (#715) * Use app.config_file_path to find server extensions This property in the base class already has the same logic to add config_dir to jupyter_config_path JupyterHub overrides this to have slightly different logic, and the same should apply here * extensions should inherit parent's config_file_path base ServerApp should have total control over config file loading --- jupyter_server/extension/application.py | 5 +++++ jupyter_server/serverapp.py | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jupyter_server/extension/application.py b/jupyter_server/extension/application.py index ea18d687d4..0b32ef4904 100644 --- a/jupyter_server/extension/application.py +++ b/jupyter_server/extension/application.py @@ -162,6 +162,11 @@ class method. This method can be set as a entry_point in def _default_open_browser(self): return self.serverapp.config["ServerApp"].get("open_browser", True) + @property + def config_file_paths(self): + """Look on the same path as our parent for config files""" + return self.serverapp.config_file_paths + # The extension name used to name the jupyter config # file, jupyter_{name}_config. # This should also match the jupyter subcommand used to launch diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 1ee4cf64b4..422f4ffb13 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -104,7 +104,6 @@ base_flags, base_aliases, ) -from jupyter_core.paths import jupyter_config_path from jupyter_client import KernelManager from jupyter_client.kernelspec import KernelSpecManager from jupyter_client.session import Session @@ -2154,11 +2153,7 @@ def find_server_extensions(self): # This enables merging on keys, which we want for extension enabling. # Regular config loading only merges at the class level, # so each level clobbers the previous. - config_paths = jupyter_config_path() - if self.config_dir not in config_paths: - # add self.config_dir to the front, if set manually - config_paths.insert(0, self.config_dir) - manager = ExtensionConfigManager(read_config_path=config_paths) + manager = ExtensionConfigManager(read_config_path=self.config_file_paths) extensions = manager.get_jpserver_extensions() for modulename, enabled in sorted(extensions.items()):