Skip to content

Commit

Permalink
Import sync from pycrdt
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Sep 13, 2024
1 parent 35984d0 commit df73aa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 8 additions & 8 deletions plugins/yjs/fps_yjs/ywidgets/widgets.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import sys
from typing import Any

from pycrdt import TransactionEvent

try:
from ypywidgets.utils import ( # type: ignore
import ypywidgets # type: ignore
from pycrdt import (
TransactionEvent,
YMessageType,
YSyncMessageType,
create_sync_message,
create_update_message,
process_sync_message,
sync,
handle_sync_message,
)
ypywidgets_installed = True
except ImportError:
Expand Down Expand Up @@ -41,15 +41,15 @@ def comm_open(self, msg, comm) -> None:
self.comm = comm
model = self.ydocs[f"{name}Model"]()
self.widgets[comm_id] = {"model": model, "comm": comm}
msg = sync(model.ydoc)
comm.send(**msg)
msg = create_sync_message(model.ydoc)
comm.send(buffers=[msg])

def comm_msg(self, msg) -> None:
comm_id = msg["content"]["comm_id"]
message = bytes(msg["buffers"][0])
if message[0] == YMessageType.SYNC:
ydoc = self.widgets[comm_id]["model"].ydoc
reply = process_sync_message(
reply = handle_sync_message(
message[1:],
ydoc,
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async def recv(self) -> bytes:
return bytes(b)


@pytest.mark.skip(reason="FIXME: caused by new ypywidgets version")
@pytest.mark.asyncio
@pytest.mark.parametrize("auth_mode", ("noauth",))
async def test_execute(auth_mode, unused_tcp_port):
Expand Down

0 comments on commit df73aa0

Please sign in to comment.