Skip to content

Commit

Permalink
Backport PR jupyter-server#834: Enable GatewayClient managers to be c…
Browse files Browse the repository at this point in the history
…onfigurable
  • Loading branch information
Zsailer authored and meeseeksmachine committed May 6, 2022
1 parent 25b8011 commit 4f5cc4e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,18 +1451,28 @@ def _observe_contents_manager_class(self, change):
)

kernel_manager_class = Type(
default_value=AsyncMappingKernelManager,
klass=MappingKernelManager,
config=True,
help=_i18n("The kernel manager class to use."),
)

@default("kernel_manager_class")
def _default_kernel_manager_class(self):
if self.gateway_config.gateway_enabled:
return "jupyter_server.gateway.managers.GatewayMappingKernelManager"
return AsyncMappingKernelManager

session_manager_class = Type(
default_value=SessionManager,
config=True,
help=_i18n("The session manager class to use."),
)

@default("session_manager_class")
def _default_session_manager_class(self):
if self.gateway_config.gateway_enabled:
return "jupyter_server.gateway.managers.GatewaySessionManager"
return SessionManager

config_manager_class = Type(
default_value=ConfigManager,
config=True,
Expand All @@ -1472,7 +1482,6 @@ def _observe_contents_manager_class(self, change):
kernel_spec_manager = Instance(KernelSpecManager, allow_none=True)

kernel_spec_manager_class = Type(
default_value=KernelSpecManager,
config=True,
help="""
The kernel spec manager class to use. Should be a subclass
Expand All @@ -1483,6 +1492,12 @@ def _observe_contents_manager_class(self, change):
""",
)

@default("kernel_spec_manager_class")
def _default_kernel_spec_manager_class(self):
if self.gateway_config.gateway_enabled:
return "jupyter_server.gateway.managers.GatewayKernelSpecManager"
return KernelSpecManager

login_handler_class = Type(
default_value=LoginHandler,
klass=web.RequestHandler,
Expand Down Expand Up @@ -1822,15 +1837,6 @@ def init_configurables(self):
# this determination, instantiate the GatewayClient config singleton.
self.gateway_config = GatewayClient.instance(parent=self)

if self.gateway_config.gateway_enabled:
self.kernel_manager_class = (
"jupyter_server.gateway.managers.GatewayMappingKernelManager"
)
self.session_manager_class = "jupyter_server.gateway.managers.GatewaySessionManager"
self.kernel_spec_manager_class = (
"jupyter_server.gateway.managers.GatewayKernelSpecManager"
)

self.kernel_spec_manager = self.kernel_spec_manager_class(
parent=self,
)
Expand Down

0 comments on commit 4f5cc4e

Please sign in to comment.