Skip to content

Commit a2cb6a9

Browse files
author
Jialin Zhang
committed
addressing a comment
1 parent c6c9393 commit a2cb6a9

File tree

6 files changed

+20
-72
lines changed

6 files changed

+20
-72
lines changed

jupyter_rtc_core/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from traitlets import Instance, Type
66
from .handlers import RouteHandler, FileIDIndexHandler
7-
from .websockets import GlobalAwarenessWebsocket, YRoomWebsocket
7+
from .websockets import YRoomWebsocket
88
from .rooms.yroom_manager import YRoomManager
99
from .outputs import OutputsManager, outputs_handlers
1010

@@ -17,8 +17,6 @@ class RtcExtensionApp(ExtensionApp):
1717
# dummy handler that verifies the server extension is installed;
1818
# # this can be deleted prior to initial release.
1919
(r"jupyter-rtc-core/get-example/?", RouteHandler),
20-
# global awareness websocket
21-
(r"api/collaboration/room/JupyterLab:globalAwareness/?", GlobalAwarenessWebsocket),
2220
# # ydoc websocket
2321
(r"api/collaboration/room/(.*)", YRoomWebsocket),
2422
# # handler that just adds compatibility with Jupyter Collaboration's frontend

jupyter_rtc_core/rooms/yroom.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def __init__(
5353
room_id: str,
5454
log: Logger,
5555
loop: asyncio.AbstractEventLoop,
56-
fileid_manager: BaseFileIdManager | None = None,
57-
contents_manager: AsyncContentsManager | ContentsManager | None = None,
56+
fileid_manager: BaseFileIdManager,
57+
contents_manager: AsyncContentsManager | ContentsManager,
5858
):
5959
# Bind instance attributes
6060
self.log = log
@@ -68,7 +68,7 @@ def __init__(
6868

6969
self.file_api = None
7070
self._jupyter_ydoc = None
71-
if fileid_manager and contents_manager:
71+
if self.room_id != "JupyterLab:globalAwareness":
7272
_, file_type, _ = self.room_id.split(":")
7373
JupyterYDocClass = cast(
7474
type[YBaseDoc],
@@ -125,6 +125,10 @@ async def get_jupyter_ydoc(self):
125125
"""
126126
if self.file_api:
127127
await self.file_api.ydoc_content_loaded
128+
if self.room_id == "JupyterLab:globalAwareness":
129+
message = "There is no Jupyter ydoc for global awareness scenario"
130+
self.log.error(message)
131+
raise Exception(message)
128132
return self._jupyter_ydoc
129133

130134

jupyter_rtc_core/rooms/yroom_manager.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ def get_room(self, room_id: str) -> YRoom | None:
4848
# Otherwise, create a new room
4949
try:
5050
self.log.info(f"Initializing room '{room_id}'.")
51-
if room_id == "JupyterLab:globalAwareness":
52-
yroom = YRoom(room_id=room_id,
53-
log=self.log,
54-
loop=self.loop)
55-
else:
56-
yroom = YRoom(
57-
room_id=room_id,
58-
log=self.log,
59-
loop=self.loop,
60-
fileid_manager=self.fileid_manager,
61-
contents_manager=self.contents_manager,
62-
)
51+
yroom = YRoom(
52+
room_id=room_id,
53+
log=self.log,
54+
loop=self.loop,
55+
fileid_manager=self.fileid_manager,
56+
contents_manager=self.contents_manager,
57+
)
6358
self._rooms_by_id[room_id] = yroom
6459
return yroom
6560
except Exception as e:
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
from .clients import YjsClient, YjsClientGroup
22
from .yroom_ws import YRoomWebsocket
3-
from .global_awareness_ws import GlobalAwarenessWebsocket

jupyter_rtc_core/websockets/global_awareness_ws.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

jupyter_rtc_core/websockets/yroom_ws.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ def prepare(self):
4141
self.room_id = request_path.strip("/").split("/")[-1]
4242

4343
# Verify the file ID contained in the room ID points to a valid file.
44-
fileid = self.room_id.split(":")[-1]
45-
path = self.fileid_manager.get_path(fileid)
46-
if not path:
47-
raise HTTPError(404, f"No file with ID '{fileid}'.")
44+
if self.room_id != "JupyterLab:globalAwareness":
45+
fileid = self.room_id.split(":")[-1]
46+
path = self.fileid_manager.get_path(fileid)
47+
if not path:
48+
raise HTTPError(404, f"No file with ID '{fileid}'.")
4849

4950

5051
def open(self, *_, **__):

0 commit comments

Comments
 (0)