|
11 | 11 | "cell_type": "markdown", |
12 | 12 | "metadata": {}, |
13 | 13 | "source": [ |
14 | | - "nbmake tests notebook documentation and is designed for notebooks which are non-deterministic.\n", |
| 14 | + "See the README for details: \n", |
15 | 15 | "\n", |
16 | | - "Despite being a pytest plugin, nbmake is kernel agnostic. It supports any language." |
17 | | - ] |
18 | | - }, |
19 | | - { |
20 | | - "cell_type": "markdown", |
21 | | - "metadata": {}, |
22 | | - "source": [ |
23 | | - "\n", |
24 | | - "## Quickstart\n", |
25 | | - "\n", |
26 | | - "```bash\n", |
27 | | - "pip install pytest nbmake\n", |
28 | | - "pytest --nbmake\n", |
29 | | - "```\n", |
30 | | - "\n", |
31 | | - "### Output\n", |
32 | | - "```\n", |
33 | | - "========================================================================================== test session starts ==========================================================================================\n", |
34 | | - "platform darwin -- Python 3.7.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1\n", |
35 | | - "rootdir: /Users/asdf/git/treebeardtech/nbmake, configfile: pytest.ini\n", |
36 | | - "plugins: nbmake-0.0.1, xdist-2.1.0, cov-2.10.1, forked-1.3.0\n", |
37 | | - "collected 1 item \n", |
38 | | - "\n", |
39 | | - "landing-page.ipynb . [100%]\n", |
40 | | - "\n", |
41 | | - "=========================================================================================== 1 passed in 1.56s ===========================================================================================\n", |
42 | | - "\n", |
43 | | - "```" |
44 | | - ] |
45 | | - }, |
46 | | - { |
47 | | - "cell_type": "markdown", |
48 | | - "metadata": {}, |
49 | | - "source": [ |
50 | | - "## Command Line Options\n", |
51 | | - "\n", |
52 | | - "Using the following options you can control how notebooks are executed, and configure CI pipelines" |
53 | | - ] |
54 | | - }, |
55 | | - { |
56 | | - "cell_type": "code", |
57 | | - "execution_count": null, |
58 | | - "metadata": { |
59 | | - "tags": [ |
60 | | - "hide-input" |
61 | | - ] |
62 | | - }, |
63 | | - "outputs": [], |
64 | | - "source": [ |
65 | | - "!pytest -h | grep -A6 'notebook testing'" |
66 | | - ] |
67 | | - }, |
68 | | - { |
69 | | - "cell_type": "markdown", |
70 | | - "metadata": {}, |
71 | | - "source": [ |
72 | | - "## Run Only Against IPYNB Files\n", |
73 | | - "\n", |
74 | | - "```\n", |
75 | | - "pytest --nbmake **/*ipynb\n", |
76 | | - "```" |
77 | | - ] |
78 | | - }, |
79 | | - { |
80 | | - "cell_type": "markdown", |
81 | | - "metadata": {}, |
82 | | - "source": [ |
83 | | - "## Create an HTML Report\n", |
84 | | - "\n", |
85 | | - "To view outputs executed remotely, install jupyter-book:\n", |
86 | | - "```\n", |
87 | | - "pip install pytest 'nbmake[html]'\n", |
88 | | - "```\n", |
89 | | - "\n", |
90 | | - "Then specify a path:\n", |
91 | | - "```\n", |
92 | | - "pytest --nbmake --path-output=.\n", |
93 | | - "```\n", |
94 | | - "\n", |
95 | | - "### Output\n", |
96 | | - "```\n", |
97 | | - "========================================================================================== test session starts ==========================================================================================\n", |
98 | | - "platform darwin -- Python 3.7.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1\n", |
99 | | - "rootdir: /Users/asdf/git/treebeardtech/nbmake, configfile: pytest.ini\n", |
100 | | - "plugins: nbmake-0.0.1, xdist-2.1.0, cov-2.10.1, forked-1.3.0\n", |
101 | | - "collected 1 item \n", |
102 | | - "\n", |
103 | | - "landing-page.ipynb . [100%]\n", |
104 | | - "\n", |
105 | | - "\n", |
106 | | - "2020-12-11 11:10:48 nbmake building test report at: \n", |
107 | | - "\n", |
108 | | - " file:///Users/asdf/git/treebeardtech/nbmake/docs/_build/html/index.html\n", |
109 | | - "\n", |
110 | | - "2020-12-11 11:10:50 done.\n", |
111 | | - "\n", |
112 | | - "=========================================================================================== 1 passed in 4.26s ===========================================================================================\n", |
113 | | - "```\n", |
114 | | - "\n", |
115 | | - "The report contains only the stripped out and executed notebooks\n", |
116 | | - "" |
117 | | - ] |
118 | | - }, |
119 | | - { |
120 | | - "cell_type": "markdown", |
121 | | - "metadata": {}, |
122 | | - "source": [ |
123 | | - "## Run and upload report on GitHub Actions using Netlify\n", |
124 | | - "\n", |
125 | | - "```yaml\n", |
126 | | - " - run: pip install pytest 'nbmake[html]'\n", |
127 | | - " - run: |\n", |
128 | | - " pytest --nbmake --path-output=.\n", |
129 | | - " - if: failure()\n", |
130 | | - " run: |\n", |
131 | | - " netlify deploy --dir=_build/html --auth=${{ secrets.NETLIFY_TOKEN }} --site=${{ secrets.NETLIFY_SITE_API_ID }}\n", |
132 | | - "```\n", |
133 | | - "```\n", |
134 | | - "...\n", |
135 | | - "- Waiting for deploy to go live...\n", |
136 | | - "✔ Deploy is live!\n", |
137 | | - "\n", |
138 | | - "Logs: https://app.netlify.com/sites/festive-payne-ce084c/deploys/5fcf58ec72dc52a440dffcd7\n", |
139 | | - "Website Draft URL: https://5fcf58ec72dc52a440dffcd7--festive-payne-ce084c.netlify.app\n", |
140 | | - "```\n", |
141 | | - "\n", |
142 | | - "Note you can also run the tests using [nbmake-action](https://github.com/treebeardtech/treebeard) for this." |
143 | | - ] |
144 | | - }, |
145 | | - { |
146 | | - "cell_type": "markdown", |
147 | | - "metadata": {}, |
148 | | - "source": [ |
149 | | - "## Disable Nbmake\n", |
150 | | - "\n", |
151 | | - "Implicitly:\n", |
152 | | - "```\n", |
153 | | - "pytest\n", |
154 | | - "```\n", |
155 | | - "\n", |
156 | | - "Explicitly:\n", |
157 | | - "```\n", |
158 | | - "pytest -p no:nbmake\n", |
159 | | - "```" |
160 | | - ] |
161 | | - }, |
162 | | - { |
163 | | - "cell_type": "markdown", |
164 | | - "metadata": {}, |
165 | | - "source": [ |
166 | | - "## Allow errors and Configure Cell Timeouts\n", |
167 | | - "\n", |
168 | | - "nbmake is designed to compatible with jupyter book config (placed in notebook `metadata`, not the global config.yml)\n", |
169 | | - "\n", |
170 | | - "See [jupyter book docs](https://jupyterbook.org/content/execute.html?highlight=allow_error#dealing-with-code-that-raises-errors)" |
171 | | - ] |
172 | | - }, |
173 | | - { |
174 | | - "cell_type": "markdown", |
175 | | - "metadata": {}, |
176 | | - "source": [ |
177 | | - "## Parallelisation\n", |
178 | | - "\n", |
179 | | - "Parallelisation with xdist is experimental upon initial release, but you can try it out:\n", |
180 | | - "```\n", |
181 | | - "pip install pytest-xdist\n", |
182 | | - "\n", |
183 | | - "pytest --nbmake -n=auto\n", |
184 | | - "```\n", |
185 | | - "\n", |
186 | | - "It is also possible to parallelise at a CI-level using strategies, see [example](https://github.com/LabForComputationalVision/plenoptic/blob/master/.github/workflows/treebeard.yml)\n", |
187 | | - "\n", |
188 | | - "### Build Jupyter Books Faster\n", |
189 | | - "\n", |
190 | | - "Using xdist and the `--overwrite` flag let you build a large jupyter book repo faster:\n", |
191 | | - "\n", |
192 | | - "```\n", |
193 | | - "pytest --nbmake --overwrite -n=auto examples\n", |
194 | | - "jb build examples\n", |
195 | | - "```" |
196 | | - ] |
197 | | - }, |
198 | | - { |
199 | | - "cell_type": "markdown", |
200 | | - "metadata": {}, |
201 | | - "source": [ |
202 | | - "## Advice on Usage\n", |
203 | | - "\n", |
204 | | - "nbmake is best used in a scenario where you use the ipynb files only for development. Consumption of notebooks is primarily done via a docs site, built through jupyter book, nbsphinx, or some other means. If using one of these tools, you are able to write assertion code in cells which will be [hidden from readers](https://jupyterbook.org/interactive/hiding.html).\n", |
205 | | - "\n", |
206 | | - "### Pre-commit\n", |
207 | | - "\n", |
208 | | - "Treating notebooks like source files lets you keep your repo minimal. Some tools, such as plotly may drop several megabytes of javascript in your output cells, as a result, stripping out notebooks on pre-commit is advisable:\n", |
209 | | - "\n", |
210 | | - "```\n", |
211 | | - "# .pre-commit-config.yaml\n", |
212 | | - "repos:\n", |
213 | | - " - repo: https://github.com/kynan/nbstripout\n", |
214 | | - " rev: master\n", |
215 | | - " hooks:\n", |
216 | | - " - id: nbstripout\n", |
217 | | - "```\n", |
218 | | - "\n", |
219 | | - "See https://pre-commit.com/ for more..." |
220 | | - ] |
221 | | - }, |
222 | | - { |
223 | | - "cell_type": "markdown", |
224 | | - "metadata": {}, |
225 | | - "source": [ |
226 | | - "## Contributing\n", |
227 | | - "\n", |
228 | | - "Feedback is the best contribution you can make as a user of this tool. Join the [Slack channel](https://join.slack.com/t/treebeard-entmoot/shared_invite/zt-jyvuqted-xBjnbvlfcu5P2ltBvn1~mg) and bug me (Alex), and raise an [issue](https://github.com/treebeardtech/nbmake/issues), even if you think you are the only person with this problem." |
229 | | - ] |
230 | | - }, |
231 | | - { |
232 | | - "cell_type": "markdown", |
233 | | - "metadata": {}, |
234 | | - "source": [ |
235 | | - "## See Also:\n", |
236 | | - "\n", |
237 | | - "* [nbmake action](https://github.com/treebeardtech/treebeard)\n", |
238 | | - "* [pytest](https://pytest.org/)\n", |
239 | | - "* [jupyter book](https://github.com/executablebooks/jupyter-book)\n", |
240 | | - "* [jupyter cache](https://github.com/executablebooks/jupyter-cache)\n", |
241 | | - "* [MyST-NB](https://github.com/executablebooks/MyST-NB)\n" |
| 16 | + "https://github.com/treebeardtech/nbmake" |
242 | 17 | ] |
243 | 18 | } |
244 | 19 | ], |
|
0 commit comments