Description
A Jupyter notebook in Davinci is a code object with the languagejupyter. It keeps the notebook’s markdown, code and saved outputs, runs its code cells in the project’s Python runtime, and exports back to a standard .ipynb file.
Importing a Notebook
Drop or upload an.ipynb file into the Library or Model to create a notebook object. The file is stored exactly as it was written, so exporting a notebook you have not changed gives back the same file. Notebooks saved in the older nbformat 3 format are upgraded to nbformat 4 on import.
To start a notebook from scratch, create a code object and set its language to jupyter.
Notebook View
Opening a notebook shows its cells in order, with each code cell’s saved outputs beneath it.- Code cells are edited in place. Changes save automatically.
- Markdown cells are shown rendered. Double-click one to edit it; it renders again when you click away. Math (
$...$,$$...$$), tables, images and attachments are supported. - Raw cells are kept as written and never run.
Code and Markdown buttons in the header add a cell below the selected cell, and Clear outputs removes every output.
Running Cells
Run all runs every code cell from the top, in one Python session, the way a fresh Jupyter kernel would. Running stops at the first cell that raises an error, and Stop halts the run.
Running a single cell first re-runs the code cells above it without changing their outputs, so the cell sees the variables and imports it expects. Only that cell’s outputs and execution count change.
Each run starts a new Python session. Variables do not carry over between runs the way they do in a long-lived Jupyter kernel.
HTML outputs are shown without running their scripts, as Jupyter does for notebooks it does not trust. Interactive widgets (
ipywidgets) and JavaScript-only outputs can’t be displayed.Project Access
Code cells have the same access to the project as Python code objects:IPython Features
Notebook code can use the IPython features notebooks commonly rely on:display()and theIPython.displayclasses (HTML,Markdown,Math,Image,JSON,SVG, …), including display handles andclear_output.- Rich object displays such as
_repr_html_and_repr_latex_, and the last expression of a cell as its output (end the line with;to hide it). - Magics:
%time,%%time,%timeit,%%timeit,%%capture,%%writefile,%run,%env,%cd,%pwd,%who,%whos,%precision,%matplotlib,%%html,%%markdown,%%latex,%%svg, and help withobject?. - Shell commands with
!command,%%bashand%%shwhen the project runs code on the server. The browser runtime has no shell. - Top-level
await.
%pip install checks whether a package is available but does not install it. Add packages to the project’s Python dependencies instead.Exporting
Use the download button in the header, orExport with the ipynb format, to save the notebook as an .ipynb file with its outputs. Notebooks that you edit or run are written in the same layout Jupyter uses.