|
1 | | -# user-tutorials |
2 | | -A set of user tutorials for SimPEG. Visit [https://simpeg.xyz/user-tutorials/](https://simpeg.xyz/user-tutorials/). |
| 1 | +# SimPEG User Tutorials |
3 | 2 |
|
4 | | -For those developing tutorials and wishing to build the website locally, some trouble shooting items are: |
| 3 | +A set of user tutorials for SimPEG. |
5 | 4 |
|
6 | | -* Updating MyST: `pip install -U mystmd` |
7 | | -* After updating, `myst clean --all` to clean cached templates |
| 5 | +**Website of the tutorials:** |
| 6 | +[https://simpeg.xyz/user-tutorials](https://simpeg.xyz/user-tutorials/). |
| 7 | + |
| 8 | + |
| 9 | +## How to build the website locally |
| 10 | + |
| 11 | +The SimPEG User Tutorials were created using [Myst][mystmd.org]. Myst is |
| 12 | +capable of building the website from content stored in [Jupyter |
| 13 | +Notebooks][jupyter]. |
| 14 | + |
| 15 | +We can build the website from the current content in the Jupyter Notebooks. |
| 16 | +This can be done in a few seconds with very slim resource requirements. |
| 17 | + |
| 18 | +Rerunning the notebooks is a more intensive task that will require significant |
| 19 | +amount of memory (specially for the computationally intensive notebooks) and it |
| 20 | +will take some time. |
| 21 | + |
| 22 | +Here you'll find instructions to: |
| 23 | + |
| 24 | +- [Build and the website locally](#build-and-serve-the-website-locally) |
| 25 | +- [Rerun notebooks in the repo](#rerun-notebooks) |
| 26 | + |
| 27 | +### Build and serve the website locally |
| 28 | + |
| 29 | +Start by cloning this repository: |
| 30 | + |
| 31 | +```bash |
| 32 | +git clone https://github.com/simpeg/user-tutorials |
| 33 | +cd user-tutorials |
| 34 | +``` |
| 35 | + |
| 36 | +To build the website you'll need to [install `mystmd`][install-mystmd]. |
| 37 | +Alternatively, you can create a `conda` environment using the `environment.yml` |
| 38 | +file: |
| 39 | + |
| 40 | +```bash |
| 41 | +conda env create -f environment.yml |
| 42 | +``` |
| 43 | + |
| 44 | +Once you have `mystmd` installed, we can now build the website from its |
| 45 | +sources. |
| 46 | + |
| 47 | +#### Build and serve |
| 48 | + |
| 49 | +The following command will build the website and serve it locally, so you can |
| 50 | +preview it. Follow the instructions that will be prompted by the command to see |
| 51 | +the website: |
| 52 | + |
| 53 | +```bash |
| 54 | +msyt start |
| 55 | +``` |
| 56 | + |
| 57 | +#### Build only |
| 58 | + |
| 59 | +The following command will build the website and store the HTML files in |
| 60 | +a new `_build` folder: |
| 61 | + |
| 62 | +```bash |
| 63 | +msyt build --html |
| 64 | +``` |
| 65 | + |
| 66 | +#### Clean cached builds |
| 67 | + |
| 68 | +```bash |
| 69 | +myst clean --all |
| 70 | +``` |
| 71 | + |
| 72 | +### Rerun notebooks |
| 73 | + |
| 74 | +Start by cloning this repository: |
| 75 | + |
| 76 | +```bash |
| 77 | +git clone https://github.com/simpeg/user-tutorials |
| 78 | +cd user-tutorials |
| 79 | +``` |
| 80 | + |
| 81 | +And create a `conda` environment using the provided `environment.yml` file: |
| 82 | + |
| 83 | +```bash |
| 84 | +conda env create -f environment.yml |
| 85 | +``` |
| 86 | + |
| 87 | +We can use `nbconvert` to rerun a notebook and overwrite its output cells |
| 88 | +in place. |
| 89 | +To rerun a single notebook, use: |
| 90 | + |
| 91 | +```bash |
| 92 | +jupyter nbconvert --to notebook --execute --inplace notebook.ipynb |
| 93 | +``` |
| 94 | + |
| 95 | +To rerun all notebooks, use: |
| 96 | + |
| 97 | +> [!CAUTION] |
| 98 | +> Rerunning all notebooks is a computationally intensive task. Some notebooks |
| 99 | +> require significant amount of memory to allocate large sensitivity matrices. |
| 100 | +
|
| 101 | +```bash |
| 102 | +jupyter nbconvert --to notebook --execute --inplace **/*.ipynb |
| 103 | +``` |
| 104 | + |
| 105 | + |
| 106 | +[install-mystmd]: https://mystmd.org/guide/quickstart |
| 107 | +[jupyter]: https://jupyter.org |
| 108 | +[mystmd.org]: https://mystmd.org |
0 commit comments