Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion jupyter_rtc_core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio

from traitlets import Instance, Type
from .handlers import RouteHandler, YRoomSessionHandler, FileIDIndexHandler
from .handlers import RouteHandler, FileIDIndexHandler
from .websockets import GlobalAwarenessWebsocket, YRoomWebsocket
from .rooms.yroom_manager import YRoomManager

Expand Down
34 changes: 1 addition & 33 deletions jupyter_rtc_core/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,4 @@ class RouteHandler(APIHandler):
def get(self):
self.finish(json.dumps({
"data": "This is /jupyter-rtc-core/get-example endpoint!"
}))


# TODO: remove this by v1.0.0 if deemed unnecessary. Just adding this for
# compatibility with the `jupyter_collaboration` frontend.
class YRoomSessionHandler(APIHandler):
SESSION_ID = str(uuid.uuid4())

@tornado.web.authenticated
def put(self, path):
body = json.loads(self.request.body)
format = body["format"]
content_type = body["type"]
# self.log.info("IN HANDLER")
# for k, v in self.settings.items():
# print(f"{k}: {v}")
# print(len(self.settings.items()))
# print(id(self.settings))

file_id_manager = self.settings["file_id_manager"]
file_id = file_id_manager.index(path)

data = json.dumps(
{
"format": format,
"type": content_type,
"fileId": file_id,
"sessionId": self.SESSION_ID,
}
)
self.set_status(200)
self.finish(data)

}))
20 changes: 17 additions & 3 deletions jupyter_rtc_core/session_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Optional, Any
from jupyter_server.services.sessions.sessionmanager import SessionManager, KernelName, ModelName
from jupyter_server.serverapp import ServerApp
Expand Down Expand Up @@ -65,10 +66,23 @@ async def create_session(
)
if kernel_id is None:
kernel_id = output["kernel"]["id"]

# Connect this session's yroom to the kernel.
if type == "notebook":
yroom = self.get_yroom(path, type)
if type == "notebook":
# If name or path is None, we cannot map to a yroom,
# so just move on.
if name is None or path is None:
self.log.debug("`name` or `path` was not given, so a yroom was not set up for this session.")
return output
# When JupyterLab creates a session, it uses a fake path
# which is the relative path + UUID, i.e. the notebook
# name is incorrect temporarily. It later makes multiple
# updates to the session to correct the path.
#
# Here, we create the true path to store in the fileID service
# by dropping the UUID and appending the file name.
real_path = os.path.join(os.path.split(path)[0], name)
yroom = self.get_yroom(real_path, type)
# TODO: we likely have a race condition here... need to
# think about it more. Currently, the kernel client gets
# created after the kernel starts fully. We need the
Expand Down
Loading