Lightning talk @ PyData London 2024 - Version Control + Notebooks (The tale of a group project)
This repo contains the slides and some Jupytext examples.
- install the requirements (
jupyterlab
,seaborn
,jupytext
,pre-commit
)pip install -r requirements.txt
- install the
pre-commit
hookspre-commit install
- start Jupyter
jupyter-lab
In this example the notebook example-1.ipynb
was created in Jupyter. The Python file (example-1.py
) was not created manually, but instead was created by Jupytext the first time the notebook was saved.
In Jupyter open the notebook example-1
, make changes to the notebook and see the same changes reflected into the .py
file as soon as the notebook is saved.
Example 1 also shows how the pre-commit
hooks will be applied to the .py
file.
In this example the notebook was not created in Jupyter. The example shows how it is possible to re-create a notebook (locally) from a Jupytext .py
files (for example, if working on the same notebook and only the Python file is commited to the git repo).
In Jupyter right-click on the example-2.py
file, select Open With
and then Notebook
. The .ipynb
file will be created, after which it will be possible to close the .py
file and start working directly on the notebook.
Example 2 also shows how changes to the notebook file wil be displayed as diff when you look at the commit history for example-2.py
. See for example the diff between 44333b27
and 3edca83c
here.