Skip to content

Commit 72e9b90

Browse files
committed
add extra dependencies guidance to jupyter style doc
1 parent cce1613 commit 72e9b90

File tree

1 file changed

+119
-2
lines changed

1 file changed

+119
-2
lines changed

docs/source/contributing/jupyter_style.md

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,123 @@ Choose a category from [existing categories](https://github.com/pymc-devs/pymc/w
5858
Authors should list people who authored, adapted or updated the notebook. See {ref}`jupyter_authors`
5959
for more details.
6060

61+
## Extra dependencies
62+
If the notebook uses libraries that are not PyMC dependencies, these extra dependencies should
63+
be indicated together with some advise on how to install them.
64+
This ensures readers know what they'll need to install beforehand and can for example
65+
decide between running it locally or on binder.
66+
67+
To make things easier for notebook writers and maintainers, pymc-examples contains
68+
a template for this that warns about the extra dependencies and provides specific
69+
installation instructions inside a dropdown.
70+
71+
Thus, notebooks with extra dependencies should:
72+
73+
1. list the extra dependencies as notebook metadata using the `myst_substitutions` category
74+
and then either the `extra_dependencies` or the `pip_dependencies` and `conda_dependencies`.
75+
In addition, there is also an `extra_install_notes` to include custom text inside the dropdown.
76+
77+
* notebook metadata can be edited from the menubar `Edit` -> `Edit notebook metadata`
78+
in the dropdown
79+
80+
This will open a window with json formatted text that might look a bit like:
81+
82+
::::{tab-set}
83+
:::{tab-item} No myst_substitutions
84+
85+
```json
86+
{
87+
"kernelspec": {
88+
"name": "python3",
89+
"display_name": "Python 3 (ipykernel)",
90+
"language": "python"
91+
},
92+
"language_info": {
93+
"name": "python",
94+
"version": "3.9.7",
95+
"mimetype": "text/x-python",
96+
"codemirror_mode": {
97+
"name": "ipython",
98+
"version": 3
99+
},
100+
"pygments_lexer": "ipython3",
101+
"nbconvert_exporter": "python",
102+
"file_extension": ".py"
103+
}
104+
}
105+
```
106+
:::
107+
108+
:::{tab-item} extra_dependencies key
109+
110+
```{code-block} json
111+
:emphasize-lines: 19-21
112+
{
113+
"kernelspec": {
114+
"name": "python3",
115+
"display_name": "Python 3 (ipykernel)",
116+
"language": "python"
117+
},
118+
"language_info": {
119+
"name": "python",
120+
"version": "3.9.7",
121+
"mimetype": "text/x-python",
122+
"codemirror_mode": {
123+
"name": "ipython",
124+
"version": 3
125+
},
126+
"pygments_lexer": "ipython3",
127+
"nbconvert_exporter": "python",
128+
"file_extension": ".py"
129+
},
130+
"myst_substitutions": {
131+
"extra_dependencies": "bambi seaborn"
132+
}
133+
}
134+
```
135+
:::
136+
137+
:::{tab-item} pip and conda specific keys
138+
```{code-block} json
139+
:emphasize-lines: 19-22
140+
{
141+
"kernelspec": {
142+
"name": "python3",
143+
"display_name": "Python 3 (ipykernel)",
144+
"language": "python"
145+
},
146+
"language_info": {
147+
"name": "python",
148+
"version": "3.9.7",
149+
"mimetype": "text/x-python",
150+
"codemirror_mode": {
151+
"name": "ipython",
152+
"version": 3
153+
},
154+
"pygments_lexer": "ipython3",
155+
"nbconvert_exporter": "python",
156+
"file_extension": ".py"
157+
},
158+
"myst_substitutions": {
159+
"pip_dependencies": "graphviz",
160+
"conda_dependencies": "python-graphviz",
161+
}
162+
}
163+
```
164+
165+
The pip and conda spcific keys overwrite the `extra_installs` one, so it doesn't make
166+
sense to use `extra_installs` is using them. Either both pip and conda substitutions
167+
are defined or none of them is.
168+
:::
169+
::::
170+
171+
1. include the warning and installation advise template with the following markdown:
172+
173+
```markdown
174+
:::{include} ../extra_installs.md
175+
:::
176+
```
177+
61178
## Code preamble
62179

63180
In a cell just below the cell where you imported matplotlib and/or ArviZ (usually the first one),
@@ -185,7 +302,7 @@ References can be cited twice within a single notebook. Two common reference for
185302

186303
which can be added inline, within the text itself. At the end of the notebook, add the bibliography with the following markdown
187304

188-
```
305+
```markdown
189306
## References
190307

191308
:::{bibliography}
@@ -195,7 +312,7 @@ which can be added inline, within the text itself. At the end of the notebook, a
195312

196313
or alternatively, if you wanted to add extra references that have not been cited within the text, use:
197314

198-
```
315+
```markdown
199316
## References
200317

201318
:::{bibliography}

0 commit comments

Comments
 (0)