Here, we provide instructions for setting up an appropriate Python environment and building the SimPEG user tutorials website locally with MyST.
The URL for the SimPEG user tutorials GitHub repository is: https://github.com/simpeg/user-tutorials/. If using the Git Bash shell:
git clone https://github.com/simpeg/user-tutorials
cd user-tutorialsThe Jupyter notebooks containing the tutorials are maintained to run properly using the latest release of SimPEG. Notebooks may not run correctly if SimPEG is being imported from an earlier release or development branch. The mystmd and nodejs are also required to build the website locally.
We advise building a Python environment from the environment.yml file in the root directory of the repository.
To create the simpeg-user-tutorials environment using conda:
conda env create -f environment.ymlOnce built, you can activate using:
conda activate simpeg-user-tutorialsThe SimPEG user tutorials are a collection of Jupyter Notebook (and Markdown) files, which MyST builds into a website. Here, we describe the commands that contributors should be familiar with.
:::{important} The tutorial notebooks, including their states, are tracked by GitHub. When the SimPEG user tutorials repository was cloned, all notebooks had been run and saved. Therefore, you do not need to rerun all of the notebooks prior to building the website! :::
The following command will build the website and serve it locally. This will allow you to preview the website and observe any changes to notebooks on the fly. To locally build and serve the website: the website:
myst startNext, follow the instructions prompted by the command to launch the local build in your brower.
The following command will build the website and store the HTML files in
a new _build folder:
myst build --htmlmyst clean --allWhen making alterations and rerunning notebooks, we typically do so by launching Jupyter Notebooks:
jupyter notebookHowever, we can rerun a notebook and overwrite its output cells in place using nbconvert.
To rerun a single notebook, use:
jupyter nbconvert --to notebook --execute --inplace notebook.ipynbWe may also want to rerun all notebooks in the repository. To rerun all notebooks, use:
jupyter nbconvert --to notebook --execute --inplace notebooks/**/*.ipynb:::{danger} Rerunning all notebooks is a computationally intensive task. Some notebooks require significant amount of memory to allocate large sensitivity matrices. :::
Important
If you are using bash as your shell, make sure to run shopt -s globstar to enable the globstar feature that allows the use of ** for
filename expansion.