Skip to content

Commit

Permalink
Bump ypywidgets, fix display_output handling (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart authored Sep 13, 2024
1 parent 20d2de0 commit b782373
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions plugins/kernels/fps_kernels/kernel_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
await self.yjs.room_manager.websocket_server.get_room(path, ydoc=doc) # type: ignore
outputs.append(doc)
else:
outputs.append(
{
"data": {"text/plain": [content["data"].get("text/plain", "")]},
"execution_count": content["execution_count"],
"metadata": {},
"output_type": msg_type,
}
)
output = {
"data": content["data"],
"metadata": {},
"output_type": msg_type,
}
if msg_type == "execute_result":
output["execution_count"] = content["execution_count"]
outputs.append(output)
elif msg_type == "error":
outputs.append(
{
Expand Down
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 # noqa: F401
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ test = [
"requests",
"websockets",
"ipykernel",
"ypywidgets >=0.7.0,<0.8.0",
"ypywidgets-textual >=0.4.0,<0.5.0",
"ypywidgets >=0.9.3,<0.10.0",
"ypywidgets-textual >=0.5.0,<0.6.0",
]
docs = [ "mkdocs", "mkdocs-material" ]

Expand Down
8 changes: 4 additions & 4 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ async def test_rest_api(start_jupyverse):
cells = json.loads(str(ycells))
assert cells[0]["outputs"] == [
{
"data": {"text/plain": ["3"]},
"execution_count": 1.0,
"data": {"text/plain": "3"},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result",
}
Expand All @@ -117,8 +117,8 @@ async def test_rest_api(start_jupyverse):
]
assert cells[2]["outputs"] == [
{
"data": {"text/plain": ["7"]},
"execution_count": 3.0,
"data": {"text/plain": "7"},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result",
}
Expand Down

0 comments on commit b782373

Please sign in to comment.