Skip to content

Commit b5de3a8

Browse files
authored
Merge pull request #12 from murphyqm/jupytext-update
Add jupyter and jupytext instructions
2 parents ad8e3e4 + 84d0b99 commit b5de3a8

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"ninoseki.vscode-mogami",
3131
"KevinRose.vsc-python-indent",
3232
"charliermarsh.ruff",
33-
"mhutchie.git-graph"
33+
"mhutchie.git-graph",
34+
"ms-toolsai.jupyter"
3435
]
3536
},
3637
},

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,39 @@ sys.path.append("src")
104104

105105
You can then run `pytest` from the main repo directory.
106106

107+
## Essential Jupytext hints
108+
109+
Create a conda env with Jupyter and Jupytext installed:
110+
111+
```
112+
conda env create --file .devcontainer/env-files/jup-env.yml
113+
```
114+
115+
Ensure you have the Jupyter extension installed.
116+
117+
To "pair" a notebook (e.g. create a `.py` plaintext version that can be version controlled), use the Jupytext CLI:
118+
119+
```
120+
jupytext --set-formats ipynb,py:percent notebook.ipynb
121+
```
122+
123+
Now you can add `.ipynb` files to your `.gitignore` and only track the `.py` version.
124+
125+
You can sync these notebooks:
126+
```
127+
jupytext --sync notebook.ipynb
128+
```
129+
130+
If you download the code to another machine (`git clone` the repository), you should only have the `.py` files.
131+
132+
You can get `jupytext` to generate the notebook output:
133+
134+
```
135+
jupytext --sync notebook.py
136+
```
137+
138+
You can also just work form the `jupytext` Python file (the Juptyer VSCode extension will allow sections of it to run as a notebook).
139+
107140
## Essential GitHub action hints
108141

109142
Under workflows, select "New workflow" and choose the "Python application" option. Change the Python version to suit your application, and modify the triggers so that you can manually run the action:

0 commit comments

Comments
 (0)