Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cell execution_state #197

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading