diff --git a/plugins/kernels/fps_kernels/kernel_driver/driver.py b/plugins/kernels/fps_kernels/kernel_driver/driver.py index 3ee7439d..c3889baf 100644 --- a/plugins/kernels/fps_kernels/kernel_driver/driver.py +++ b/plugins/kernels/fps_kernels/kernel_driver/driver.py @@ -216,9 +216,19 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]): msg_type = msg["header"]["msg_type"] content = msg["content"] if msg_type == "stream": - if (not outputs) or (outputs[-1]["name"] != content["name"]): # type: ignore - outputs.append({"name": content["name"], "output_type": msg_type, "text": []}) - outputs[-1]["text"].append(content["text"]) # type: ignore + with outputs.doc.transaction(): + if (not outputs) or (outputs[-1]["name"] != content["name"]): # type: ignore + outputs.append( + Map( + { + "name": content["name"], + "output_type": msg_type, + "text": Array([content["text"]]), + } + ) + ) + else: + outputs[-1]["text"].append(content["text"]) # type: ignore elif msg_type in ("display_data", "execute_result"): if "application/vnd.jupyter.ywidget-view+json" in content["data"]: # this is a collaborative widget diff --git a/pyproject.toml b/pyproject.toml index da4ca275..90c11235 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ test = [ "websockets", "ipykernel", "ypywidgets >=0.5.0,<0.6.0", + "ypywidgets-textual", ] docs = [ "mkdocs", "mkdocs-material" ] @@ -105,7 +106,7 @@ frontend = ["jupyterlab", "retrolab"] auth = ["noauth", "auth", "auth_fief", "auth_jupyterhub"] [tool.hatch.envs.dev.scripts] -test = "pytest ./tests plugins/webdav/tests -v --reruns 5 --timeout=60" +test = "pytest ./tests plugins/webdav/tests -v --timeout=60" lint = [ "ruff format jupyverse jupyverse_api notebooks plugins tests", "ruff check jupyverse jupyverse_api notebooks plugins tests --fix", diff --git a/tests/data/notebook1.ipynb b/tests/data/notebook1.ipynb index 29ebbf27..e1c94429 100644 --- a/tests/data/notebook1.ipynb +++ b/tests/data/notebook1.ipynb @@ -4,22 +4,12 @@ "execution_count": null, "outputs": [], "id": "a7243792-6f06-4462-a6b5-7e9ec604348e", - "source": "from ypywidgets import Widget, reactive", + "source": "from ypywidgets_textual.switch import Switch", "cell_type": "code", "metadata": { "trusted": false } }, - { - "metadata": { - "trusted": false - }, - "cell_type": "code", - "id": "dc428ca1-d2f1-4dc1-8811-6be77103d683", - "execution_count": null, - "source": "class Switch(Widget):\n value = reactive(False)\n def __init__(self) -> None:\n super().__init__(primary=True)\n def toggle(self):\n self.value = not self.value", - "outputs": [] - }, { "id": "a7243792-6f06-4462-a6b5-7e9ec604348f", "source": "switch = Switch()\nswitch", diff --git a/tests/test_server.py b/tests/test_server.py index 124808e2..9361d0fd 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -175,7 +175,7 @@ def callback(aevent, events, event): # wait for file to be loaded and Y model to be created in server and client await asyncio.sleep(0.5) # execute notebook - for cell_idx in range(3): + for cell_idx in range(2): response = requests.post( f"{url}/api/kernels/{kernel_id}/execute", data=json.dumps( @@ -200,7 +200,7 @@ def callback(aevent, events, event): data=json.dumps( { "document_id": document_id, - "cell_idx": 3, + "cell_idx": 2, } ), )