Skip to content

Commit eb9bf30

Browse files
Fix get_kernel_path for AsyncFileManagers. (#929)
1 parent 19c716b commit eb9bf30

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

jupyter_server/services/contents/filemanager.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,3 +904,13 @@ async def is_hidden(self, path):
904904
path = path.strip("/")
905905
os_path = self._get_os_path(path=path)
906906
return is_hidden(os_path, self.root_dir)
907+
908+
async def get_kernel_path(self, path, model=None):
909+
"""Return the initial API path of a kernel associated with a given notebook"""
910+
if await self.dir_exists(path):
911+
return path
912+
if "/" in path:
913+
parent_dir = path.rsplit("/", 1)[0]
914+
else:
915+
parent_dir = ""
916+
return parent_dir

jupyter_server/services/sessions/sessionmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ async def create_session(
271271
async def start_kernel_for_session(self, session_id, path, name, type, kernel_name):
272272
"""Start a new kernel for a given session."""
273273
# allow contents manager to specify kernels cwd
274-
kernel_path = self.contents_manager.get_kernel_path(path=path)
274+
kernel_path = await ensure_async(self.contents_manager.get_kernel_path(path=path))
275275
kernel_id = await self.kernel_manager.start_kernel(
276276
path=kernel_path,
277277
kernel_name=kernel_name,

0 commit comments

Comments
 (0)