From 91c3b9a007e2b7eb3d22f4d53423caabef55fda0 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Wed, 15 Nov 2023 10:32:07 +0100 Subject: [PATCH] Add cell execution_state --- jupyter_ydoc/ynotebook.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 7452263..0c3ea09 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -38,6 +38,7 @@ class YNotebook(YBaseDoc): "cell_type": str, "source": YText, "metadata": YMap, + "execution_state": str, "execution_count": Int | None, "outputs": [] | None, "attachments": {} | None @@ -100,6 +101,7 @@ def get_cell(self, index: int) -> Dict[str, Any]: """ meta = self._ymeta.to_py() cell = self._ycells[index].to_py() + cell.pop("execution_state", None) cast_all(cell, float, int) # cells coming from Yjs have e.g. execution_count as float if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4: # strip cell IDs if we have notebook format 4.0-4.4 @@ -164,6 +166,7 @@ def create_ycell(self, value: Dict[str, Any]) -> Map: output["text"] = Array(output.get("text", [])) outputs[idx] = Map(output) cell["outputs"] = Array(outputs) + cell["execution_state"] = "idle" return Map(cell)