Skip to content

Commit

Permalink
Add pending_requests
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Apr 11, 2024
1 parent d136fc3 commit 68ec61d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class YNotebook(YBaseDoc):
"cell_type": str,
"source": YText,
"metadata": YMap,
"pending_requests": YArray[
YMap[
"id": str,
"type": str
]
],
"execution_count": Int | None,
"outputs": [] | None,
"attachments": {} | None
Expand Down Expand Up @@ -99,6 +105,9 @@ def get_cell(self, index: int) -> Dict[str, Any]:
"""
meta = self._ymeta.to_py()
cell = self._ycells[index].to_py()
if "pending_requests" in cell:
# requests are not a part of notebook format, but a run-time only property
del cell["pending_requests"]
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 @@ -158,6 +167,7 @@ def create_ycell(self, value: Dict[str, Any]) -> Map:
del cell["attachments"]
elif cell_type == "code":
cell["outputs"] = Array(cell.get("outputs", []))
cell["pending_requests"] = Array([])

return Map(cell)

Expand Down

0 comments on commit 68ec61d

Please sign in to comment.