|
| 1 | +import os |
1 | 2 | from typing import Optional, Any |
2 | 3 | from jupyter_server.services.sessions.sessionmanager import SessionManager, KernelName, ModelName |
3 | 4 | from jupyter_server.serverapp import ServerApp |
@@ -65,10 +66,23 @@ async def create_session( |
65 | 66 | ) |
66 | 67 | if kernel_id is None: |
67 | 68 | kernel_id = output["kernel"]["id"] |
68 | | - |
| 69 | + |
69 | 70 | # Connect this session's yroom to the kernel. |
70 | | - if type == "notebook": |
71 | | - yroom = self.get_yroom(path, type) |
| 71 | + if type == "notebook": |
| 72 | + # If name or path is None, we cannot map to a yroom, |
| 73 | + # so just move on. |
| 74 | + if name is None or path is None: |
| 75 | + self.log.debug("`name` or `path` was not given, so a yroom was not set up for this session.") |
| 76 | + return output |
| 77 | + # When JupyterLab creates a session, it uses a fake path |
| 78 | + # which is the relative path + UUID, i.e. the notebook |
| 79 | + # name is incorrect temporarily. It later makes multiple |
| 80 | + # updates to the session to correct the path. |
| 81 | + # |
| 82 | + # Here, we create the true path to store in the fileID service |
| 83 | + # by dropping the UUID and appending the file name. |
| 84 | + real_path = os.path.join(os.path.split(path)[0], name) |
| 85 | + yroom = self.get_yroom(real_path, type) |
72 | 86 | # TODO: we likely have a race condition here... need to |
73 | 87 | # think about it more. Currently, the kernel client gets |
74 | 88 | # created after the kernel starts fully. We need the |
|
0 commit comments