Module datapane.client.api.ipython_utils

Datapane helper functions to improve the Datapane UX in IPython notebooks


def block_to_iframe(block: BaseElement) ‑> str

Convert a Block to HTML, placed within an iFrame

def read_notebook_json(path: Path) ‑> dict

Read a notebook IPYNB file

def get_jupyter_notebook_json() ‑> dict

Get the JSON for the current Jupyter notebook

def get_vscode_notebook_json() ‑> dict

Get the JSON for the current VSCode notebook

def get_colab_notebook_json() ‑> dict

Get the JSON for the current Colab notebook

def get_notebook_json() ‑> dict

Get the JSON for the current Jupyter, Colab, or VSCode notebook

def output_cell_to_block(cell: dict, ipython_output_cache: dict) ‑> typing.Optional[BaseElement]

Convert a IPython notebook output cell to a Datapane Block

def cells_to_blocks(ipython_output_cache: dict, opt_out: bool = True) ‑> typing.List[BaseElement]

Convert IPython notebook cells to a list of Datapane Blocks

Recognized cell tags: - dp-exclude - Exclude this cell (when opt_out=True) - dp-include - Include this cell (when opt_out=False) - dp-show-code - Show the input code for this cell

Note: IPython output caching must be enabled for this function to work. It is enabled by default.