Skip to content

Commit 153ab74

Browse files
committed
preliminary contributors instructions
1 parent dae4eed commit 153ab74

File tree

6 files changed

+386
-1
lines changed

6 files changed

+386
-1
lines changed

myst.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ project:
115115
children:
116116
- file: notebooks/12-pgi-inversion/plot_inv_1_joint_pf_pgi_full_info_tutorial.ipynb
117117
- file: notebooks/12-pgi-inversion/plot_inv_2_joint_pf_pgi_no_info_tutorial.ipynb
118+
- file: notebooks/contributing_index.md
119+
children:
120+
- file: notebooks/getting_started.md
121+
- file: notebooks/notebook_formatting.md
122+
- file: notebooks/generating_pr.md
118123

119124
site:
120125
template: book-theme

notebooks/03-gravity/fwd_gravity_gradiometry_3d.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@
782782
"name": "python",
783783
"nbconvert_exporter": "python",
784784
"pygments_lexer": "ipython3",
785-
"version": "3.10.15"
785+
"version": "3.10.16"
786786
}
787787
},
788788
"nbformat": 4,

notebooks/contributing_index.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Contributing to User-Tutorials
2+
==============================
3+
4+
User tutorials have become the primary resource for SimPEG users to learn the code base and best-practices for computational geophysics.
5+
To ensure a high level of consistency and quality, specific guidelines need to be followed when adding new tutorial notebooks.
6+
New tutorial notebooks will not be published until our guidelines have been followed.
7+
8+
Before You Create a Tutorial
9+
----------------------------
10+
11+
Although we greatly appreciate efforts by the SimPEG community to create new tutorials,
12+
we must ensure the contents of the tutorial are appropriate. As a result,
13+
we discourage tutorials that fall into the following categories:
14+
15+
* the tutorial focusses on functionality that is not part of SimPEG
16+
* the amount of SimPEG functionality that has not already been covered in another tutorial is insufficient
17+
* the tutorial focusses on a data-specific result and is not generalizable
18+
* the tutorial was created for purpose of self promotion
19+
20+
21+
How to Contribute
22+
-----------------
23+
24+
To add a new notebook to SimPEG user tutorials, you will need to complete the following three steps:
25+
26+
1. Follow the instructions on the [Cloning the Repository and Building the Website](getting_started.md) page.
27+
These instructions explain how to clone the SimPEG user tutorials repository, setup the appropriate Python
28+
environment, and build the website locally with MyST.
29+
30+
2. Create a notebook according to the [Structure and Formatting for Notebooks](notebook_formatting.md) page.
31+
32+
3. Create a GitHub pull request.

notebooks/generating_pr.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
GitHub Pull Request and Review
2+
==============================
3+
4+
Requirements Checklist
5+
----------------------
6+
7+
The following is a useful checklist for determining whether a new tutorial notebook follows our guidelines:
8+
9+
* **The introduction is complete:**
10+
* Title and author added to notebook
11+
* Admonitions for notebook difficulty and computational resources have been added
12+
* Keywords list has been added
13+
* Summary paragraph describing the tutorial has been added
14+
* Learning objectives have been listed
15+
* Hyperlinks to other tutorial notebooks added if necessary
16+
* **For each section:**
17+
* Short summary of what is being done
18+
* Newly introduced functionality is explained or a link is provided to a relevant notebook
19+
* Links to API documentation added for all classes and functions that are used
20+
* Data, models, etc... are plotted appropriately
21+
* Coding cells have been linted according to the [style guides](https://docs.simpeg.xyz/latest/content/getting_started/contributing/code-style.html).

notebooks/getting_started.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
Cloning the Repository and Building the Website Locally
2+
=======================================================
3+
4+
## Cloning the GitHub Repository
5+
6+
The GitHub repository for SimPEG User Tutorials can cloned from https://github.com/simpeg/user-tutorials/.
7+
If using the Git Bash shell:
8+
9+
```bash
10+
git clone https://github.com/simpeg/user-tutorials
11+
cd user-tutorials
12+
```
13+
14+
## Setting Up Your Python Environment
15+
16+
The notebooks are maintained so that they run correctly using the latest SimPEG release. Some notebooks may not
17+
run correctly if SimPEG is being imported from an earlier release or development branch. The website is built
18+
from the collection of Markdown files and Jupyter notebooks using [Myst][mystmd.org]. To build the website locally,
19+
you will need to [install `mystmd`][install-mystmd]
20+
21+
For contributors, an `environment.yml` file has been provided in the root directory of the repository.
22+
To create the environment using conda:
23+
24+
```bash
25+
conda env create -f environment.yml
26+
```
27+
28+
## How to build the website locally
29+
30+
The SimPEG User Tutorials were created using [Myst][mystmd.org]. Myst is
31+
capable of building the website from content stored in [Jupyter
32+
Notebooks][jupyter].
33+
34+
We can build the website from the current content in the Jupyter Notebooks.
35+
This can be done in a few seconds with very slim resource requirements.
36+
37+
Rerunning the notebooks is a more intensive task that will require significant
38+
amount of memory (specially for the computationally intensive notebooks) and it
39+
will take some time.
40+
41+
Here you'll find instructions to:
42+
43+
- [Build and the website locally](#build-and-serve-the-website-locally)
44+
- [Rerun notebooks in the repo](#rerun-notebooks)
45+
46+
### Build and Serve the Website Locally
47+
48+
#### Build and Serve
49+
50+
The following command will build the website and serve it locally, so you can
51+
preview it. Follow the instructions that will be prompted by the command to see
52+
the website:
53+
54+
```bash
55+
msyt start
56+
```
57+
58+
#### Build Only
59+
60+
The following command will build the website and store the HTML files in
61+
a new `_build` folder:
62+
63+
```bash
64+
msyt build --html
65+
```
66+
67+
#### Clean Cached Builds
68+
69+
```bash
70+
myst clean --all
71+
```
72+
73+
### Rerun Notebooks
74+
75+
Start by cloning this repository:
76+
77+
```bash
78+
git clone https://github.com/simpeg/user-tutorials
79+
cd user-tutorials
80+
```
81+
82+
And create a `conda` environment using the provided `environment.yml` file:
83+
84+
```bash
85+
conda env create -f environment.yml
86+
```
87+
88+
We can use `nbconvert` to rerun a notebook and overwrite its output cells
89+
in place.
90+
To rerun a single notebook, use:
91+
92+
```bash
93+
jupyter nbconvert --to notebook --execute --inplace notebook.ipynb
94+
```
95+
96+
To rerun all notebooks, use:
97+
98+
> [!CAUTION]
99+
> Rerunning all notebooks is a computationally intensive task. Some notebooks
100+
> require significant amount of memory to allocate large sensitivity matrices.
101+
102+
> [!IMPORTANT]
103+
> If you are using bash as your shell, make sure to run `shopt -s
104+
> globstar` to enable the `globstar` feature that allows the use of `**` for
105+
> filename expansion.
106+
107+
```bash
108+
jupyter nbconvert --to notebook --execute --inplace notebooks/**/*.ipynb
109+
```
110+
111+
112+
[install-mystmd]: https://mystmd.org/guide/quickstart
113+
[jupyter]: https://jupyter.org
114+
[mystmd.org]: https://mystmd.org
115+
116+
117+
## Check Style of Notebooks
118+
119+
We can check the code style of our notebooks using [`ruff`][ruff] and
120+
[`nbqa`][nbqa]. Simply run the following command to check the style of the
121+
notebooks:
122+
123+
```bash
124+
nbqa ruff notebooks
125+
```
126+
127+
And run this to autoformat them:
128+
129+
```bash
130+
nbqa ruff --fix notebooks
131+
```
132+
133+
Alternatively, you can use the targets we have in the `Makefile`, like `make
134+
check` and `make format`. Read more information about the available targets
135+
by running `make help`.

0 commit comments

Comments
 (0)