Skip to content

Commit 643765d

Browse files
committed
separate extensions listed in jupyter config from extensions explicitely passed to the ServerApp
1 parent b9b5c7d commit 643765d

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

jupyter_server/extension/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def initialize_server(cls, argv=[], load_other_extensions=True, **kwargs):
316316
}
317317
})
318318
serverapp = ServerApp.instance(**kwargs, argv=[], config=config)
319-
serverapp.initialize(argv=argv, load_extensions=load_other_extensions)
319+
serverapp.initialize(argv=argv, find_extensions=load_other_extensions)
320320
return serverapp
321321

322322
def link_to_serverapp(self, serverapp):

jupyter_server/serverapp.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,18 +1482,12 @@ def init_components(self):
14821482
# TODO: this should still check, but now we use bower, not git submodule
14831483
pass
14841484

1485-
def init_server_extensions(self):
1485+
def find_server_extensions(self):
14861486
"""
14871487
Searches Jupyter paths for jpserver_extensions and captures
14881488
metadata for all enabled extensions.
1489-
1490-
If an extension's metadata includes an 'app' key,
1491-
the value must be a subclass of ExtensionApp. An instance
1492-
of the class will be created at this step. The config for
1493-
this instance will inherit the ServerApp's config object
1494-
and load its own config.
14951489
"""
1496-
# Step 1: Walk through all config files looking for jpserver_extensions.
1490+
# Walk through all config files looking for jpserver_extensions.
14971491
#
14981492
# Each extension will likely have a JSON config file enabling itself in
14991493
# the "jupyter_server_config.d" directory. Find each of these and
@@ -1521,7 +1515,15 @@ def init_server_extensions(self):
15211515
self.config.ServerApp.jpserver_extensions.update({modulename: enabled})
15221516
self.jpserver_extensions.update({modulename: enabled})
15231517

1524-
# Step 2: Load extension metadata for enabled extensions, load config for
1518+
def init_server_extensions(self):
1519+
"""
1520+
If an extension's metadata includes an 'app' key,
1521+
the value must be a subclass of ExtensionApp. An instance
1522+
of the class will be created at this step. The config for
1523+
this instance will inherit the ServerApp's config object
1524+
and load its own config.
1525+
"""
1526+
# Load extension metadata for enabled extensions, load config for
15251527
# enabled ExtensionApps, and store enabled extension metadata in the
15261528
# _enabled_extensions attribute.
15271529
#
@@ -1749,17 +1751,18 @@ def _init_asyncio_patch():
17491751
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
17501752

17511753
@catch_config_error
1752-
def initialize(self, argv=None, load_extensions=True, new_httpserver=True):
1754+
def initialize(self, argv=None, find_extensions=True, new_httpserver=True):
17531755
"""Initialize the Server application class, configurables, web application, and http server.
17541756
17551757
Parameters
17561758
----------
17571759
argv: list or None
17581760
CLI arguments to parse.
17591761
1760-
load_extensions: bool
1761-
If True, the server will load server extensions listed in the jpserver_extension trait.
1762-
Otherwise, no server extensions will be loaded.
1762+
find_extensions: bool
1763+
If True, find and load extensions listed in Jupyter config paths. If False,
1764+
only load extensions that are passed to ServerApp directy through
1765+
the `argv`, `config`, or `jpserver_extensions` arguments.
17631766
17641767
new_httpserver: bool
17651768
If True, a tornado HTTPServer instance will be created and configured for the Server Web
@@ -1769,11 +1772,11 @@ def initialize(self, argv=None, load_extensions=True, new_httpserver=True):
17691772
# Parse command line, load ServerApp config files,
17701773
# and update ServerApp config.
17711774
super(ServerApp, self).initialize(argv)
1772-
17731775
# Then, use extensions' config loading mechanism to
17741776
# update config. ServerApp config takes precedence.
1775-
if load_extensions:
1776-
self.init_server_extensions()
1777+
if find_extensions:
1778+
self.find_server_extensions()
1779+
self.init_server_extensions()
17771780
# Initialize all components of the ServerApp.
17781781
self.init_logging()
17791782
if self._dispatching:
@@ -1785,8 +1788,7 @@ def initialize(self, argv=None, load_extensions=True, new_httpserver=True):
17851788
self.init_httpserver()
17861789
self.init_terminals()
17871790
self.init_signal()
1788-
if load_extensions:
1789-
self.load_server_extensions()
1791+
self.load_server_extensions()
17901792
self.init_mime_overrides()
17911793
self.init_shutdown_no_activity()
17921794

0 commit comments

Comments
 (0)