Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydrate a Kernel Manager when calling GatewayKernelManager.start_kernel with a kernel_id #788

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions jupyter_server/gateway/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def start_kernel(self, kernel_id=None, path=None, **kwargs):
kwargs["cwd"] = self.cwd_for_path(path)

km = self.kernel_manager_factory(parent=self, log=self.log)
await km.start_kernel(**kwargs)
await km.start_kernel(kernel_id=kernel_id, **kwargs)
kernel_id = km.kernel_id
self._kernels[kernel_id] = km

Expand Down Expand Up @@ -368,6 +368,7 @@ async def refresh_model(self, model=None):
self.log.debug("Request kernel at: %s" % self.kernel_url)
try:
response = await gateway_request(self.kernel_url, method="GET")

except web.HTTPError as error:
if error.status_code == 404:
self.log.warning("Kernel not found at: %s" % self.kernel_url)
Expand Down Expand Up @@ -434,14 +435,14 @@ async def start_kernel(self, **kwargs):
response = await gateway_request(self.kernels_url, method="POST", body=json_body)
self.kernel = json_decode(response.body)
self.kernel_id = self.kernel["id"]
self.kernel_url = url_path_join(self.kernels_url, url_escape(str(self.kernel_id)))
self.log.info(f"GatewayKernelManager started kernel: {self.kernel_id}, args: {kwargs}")
else:
self.kernel_id = kernel_id
self.kernel_url = url_path_join(self.kernels_url, url_escape(str(self.kernel_id)))
self.kernel = await self.refresh_model()
self.log.info(f"GatewayKernelManager using existing kernel: {self.kernel_id}")

self.kernel_url = url_path_join(self.kernels_url, url_escape(str(self.kernel_id)))

async def shutdown_kernel(self, now=False, restart=False):
"""Attempts to stop the kernel process cleanly via HTTP."""

Expand Down