Skip to content

Commit

Permalink
Use pycrdt-websocket instead of ypy-websocket (jupyterlab#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart authored and andrii-i committed Feb 11, 2025
1 parent 6d4ccde commit f4d23d6
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/source/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jupyter lab --YDocExtension.file_poll_interval=2
# If None, the document will be kept in memory forever.
jupyter lab --YDocExtension.document_cleanup_delay=100

# The Store class used for storing Y updates (default: SQLiteYStore).
jupyter lab --YDocExtension.ystore_class=jupyter_collaboration.stores.FileYStore
# The YStore class to use for storing Y updates (default: JupyterSQLiteYStore).
jupyter lab --YDocExtension.ystore_class=pycrdt_websocket.ystore.TempFileYStore
```
1 change: 1 addition & 0 deletions jupyter_collaboration/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio

from jupyter_server.extension.application import ExtensionApp
from pycrdt_websocket.ystore import BaseYStore
from traitlets import Bool, Float, Type

from .handlers import DocSessionHandler, YDocWebSocketHandler
Expand Down
4 changes: 3 additions & 1 deletion jupyter_collaboration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from jupyter_server.auth import authorized
from jupyter_server.base.handlers import APIHandler, JupyterHandler
from jupyter_ydoc import ydocs as YDOCS
from pycrdt_websocket.websocket_server import YRoom
from pycrdt_websocket.ystore import BaseYStore
from pycrdt_websocket.yutils import YMessageType, write_var_uint
from tornado import web
from tornado.ioloop import IOLoop
from tornado.websocket import WebSocketHandler
from ypy_websocket.yutils import write_var_uint

from .rooms import BaseRoom, RoomManager
from .stores import BaseYStore
Expand Down
4 changes: 3 additions & 1 deletion jupyter_collaboration/rooms/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

from jupyter_events import EventLogger
from jupyter_ydoc import ydocs as YDOCS
from ypy_websocket.yutils import write_var_uint
from pycrdt_websocket.websocket_server import YRoom
from pycrdt_websocket.ystore import BaseYStore, YDocNotFound
from pycrdt_websocket.yutils import write_var_uint

from ..loaders import FileLoader
from ..stores import BaseYStore
Expand Down
9 changes: 2 additions & 7 deletions jupyter_collaboration/stores/stores.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from __future__ import annotations

from logging import Logger

from pycrdt_websocket.ystore import SQLiteYStore as _SQLiteYStore
from pycrdt_websocket.ystore import TempFileYStore as _TempFileYStore
from traitlets import Int, Unicode
from traitlets.config import LoggingConfigurable

from .file_store import FileYStore
from .sqlite_store import SQLiteYStore as _SQLiteYStore


class TempFileYStore(FileYStore):
def __init__(self, log: Logger | None = None):
Expand Down
3 changes: 2 additions & 1 deletion jupyter_collaboration/websocketserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from logging import Logger
from typing import Any

from pycrdt_websocket.websocket_server import WebsocketServer, YRoom
from pycrdt_websocket.ystore import BaseYStore
from tornado.websocket import WebSocketHandler
from ypy_websocket.websocket_server import WebsocketServer, YRoom


class RoomNotFound(LookupError):
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ classifiers = [
]
dependencies = [
"jupyter_server>=2.0.0,<3.0.0",
"jupyter_ydoc>=1.1.0a0,<2.0.0",
"ypy-websocket>=0.12.1,<0.13.0",
"jupyter_ydoc>=2.0.0,<3.0.0",
"pycrdt-websocket>=0.12.5,<0.13.0",
"jupyter_events>=0.7.0",
"jupyter_server_fileid>=0.7.0,<1",
"jsonschema>=4.18.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import nbformat
import pytest
from jupyter_ydoc import YNotebook, YUnicode
from pycrdt_websocket import WebsocketProvider
from websockets import connect
from ypy_websocket import WebsocketProvider

from jupyter_collaboration.loaders import FileLoader
from jupyter_collaboration.rooms import DocumentRoom
Expand Down
2 changes: 1 addition & 1 deletion tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any

from jupyter_ydoc import YUnicode
from ypy_websocket import WebsocketProvider
from pycrdt_websocket import WebsocketProvider


async def test_session_handler_should_create_a_session_without_session_id(
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any

from jupyter_server import _tz as tz
from ypy_websocket.yutils import write_var_uint
from pycrdt_websocket.yutils import write_var_uint

from jupyter_collaboration.utils import RoomMessages

Expand Down

0 comments on commit f4d23d6

Please sign in to comment.