MCPcopy Create free account
hub / github.com/datapane/datapane / output_cell_to_block

Function output_cell_to_block

python-client/src/datapane/ipython/utils.py:19–31  ·  view source on GitHub ↗

Convert a IPython notebook output cell to a Datapane Block

(cell: dict, ipython_output_cache: dict)

Source from the content-addressed store, hash-verified

17
18
19def output_cell_to_block(cell: dict, ipython_output_cache: dict) -> typing.Optional[BaseBlock]:
20 """Convert a IPython notebook output cell to a Datapane Block"""
21 from datapane.blocks import wrap_block
22
23 # Get the output object from the IPython output cache
24 cell_output_object = ipython_output_cache.get(cell["execution_count"], None)
25
26 # If there's no corresponding output object, skip
27 if cell_output_object is not None:
28 with suppress(Exception):
29 return wrap_block(cell_output_object)
30
31 return None
32
33
34def check_notebook_cache_parity(notebook_json: dict, ipython_input_cache: list) -> typing.Tuple[bool, typing.List[int]]:

Callers 1

cells_to_blocksFunction · 0.85

Calls 2

wrap_blockFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected