Skip to content

Commit 9be348f

Browse files
authored
Add tutorials section to cookbook (#16)
* Add tutorials * split cookbook and tutorials into two different pages * add new basic introductionary tutorial * add the old OpenMM 7 tutorials as is from existing docs * Update gh-pages.yml set follow_symlinks to true otherwise the "latest" symlink in gh-pages branch causes issues with build process * split cookbook and tutorial pages * clean up alchemical free energy tutorial * cleanup and update readme * get back default thumbnails
1 parent 3ca5c00 commit 9be348f

17 files changed

+6852
-71
lines changed

.github/workflows/gh-pages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
jekyll: false
101101
commit_message: "Deploy to GH Pages"
102102
keep_history: true
103+
follow_symlinks: true
103104
env:
104105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105106

@@ -122,4 +123,4 @@ jobs:
122123
issue-number: ${{ github.event.pull_request.number }}
123124
body: |
124125
Example docs for this PR [rendered here](https://openmm.github.io/openmm-cookbook/PR${{ github.event.number }})
125-
edit-mode: replace
126+
edit-mode: replace

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
# openmm-cookbook
2-
Proof-of-concept for the OpenMM Cookbook.
2+
3+
This repo is home to the OpenMM Cookbook and the OpenMM Tutorials
34

45
Preview at https://openmm.github.io/openmm-cookbook
56

67
## Adding a notebook
78

8-
A notebooks can be added to the cookbook by adding it to a subfolder of the `notebooks` folder. Links to download the notebook, view it in GitHub, or open it in Google Colab are added to the rendered notebook on the website automatically. Any files required by the notebook should be placed in the same folder as the notebook --- they are required by both the testing apparatus and Google Colab. The notebook must also be added to `index.md`.
9+
To add a new cookbook add the ipynb notebook to the `notebooks/cookbook` folder and add a link to it in `cookbook.md`. To add a new tutorial add the ipynb notebook to the `notebooks/tutorials` folder and add a link to it in `tutorials.md`
10+
11+
Links to download the notebook, view it in GitHub, or open it in Google Colab are added to the rendered notebook on the website automatically. Any files required by the notebook should be placed in the same folder as the notebook --- they are required by both the testing apparatus and Google Colab. The notebook must also be added to `index.md`.
912

1013
"Open in Google Colab" links to a copy of the notebook that is constructed when the documentation is built. This copy has a cell injected that allows the notebook's dependencies to be installed automatically. By default, each notebook will install the Conda Forge packages specified in the `cookbook_default_conda_forge_deps` variable in `conf.py`, and then download all the files in the notebook's folder into the notebook's execution environment. This can be configured on a per-notebook basis by adding the `conda_forge_dependencies` or `required_files` metadata entries to the notebook.
1114

12-
Notebook thumbnails can be configured in several ways, as described in the [nbsphinx documentation].
15+
Notebook thumbnails can be configured in several ways, as described in the [nbsphinx documentation](https://nbsphinx.readthedocs.io/).
16+
17+
18+
## Building locally
19+
20+
First clone this repo, then create a conda environment using [environment.yml](environment.yml).
21+
The cookbook can then be built using
22+
```
23+
make html
24+
```
25+
the created html will be in the `build/html` directory and can be viewed by opening `build/html/index.html` in a browser.
1326

1427
## Releases
1528

16-
The cookbook's `main` branch is intended for use with the latest release of OpenMM. When new cookbooks are added, they will be served immediately and tested against the current release. Nightly tests are performed against OpenMM's development branch, and any fixes required will live in feature branches or a `next` branch. When a new release of OpenMM is cut, the state of `main`, which reflects an entire release cycle, is memorialized with a release tag and rendered to gh-pages in its own release folder. Any feature branches or `next` branches are then merged in so that `main` is now compatible with the new release.
29+
The cookbooks main branch is the development channel, it is rendered as `https://openmm.github.io/openmm-cookbook/dev/`, anytime the main branch is updated the rendered cookbook will be updated.
30+
31+
When a release is cut the current working state of the cookbook will be preserved as `https://openmm.github.io/openmm-cookbook/refs/tags/${release}/index.html` where `${release}` is the release tag. e.g. `https://openmm.github.io/openmm-cookbook/refs/tags/v0.1/index.html`.
32+
33+
34+
The latest version of the cookbook will point to the most recent release `https://openmm.github.io/openmm-cookbook/latest/`
35+
36+
## CI
37+
38+
Continuous integration is run on the main branch of the cookbook. Just the notebooks in `notebooks/cookbook` are run through the CI, tutorials are not (due to long compute time). There are two workflows: [Main](.github/workflows/ci-main.yml) will test that the notebooks run with the latest release of OpenMM, [Nightly](.github/workflows/ci-nightly.yml) will test that the notebooks run with the development version of OpenMM.
39+
40+
## Pull Requests
41+
42+
When a PR is triggered the cookbook will be rendered as `https://openmm.github.io/openmm-cookbook/PR#/` where PR# is the pull request number e.g. [PR16](https://openmm.github.io/openmm-cookbook/PR16/index.html). **Note** that due to github actions permissions the *Deploy to GitHub Pages* step in the [gh-pages workflow](.github/workflows/gh-pages.yml) will only work correctly if the PR comes from a branch *within* `https://github.com/openmm/openmm-cookbook` and it will not work when the PR comes from a personal fork.
43+
44+
1745

18-
This strategy allows cookbooks for the current version to be released instantly while still permitting testing of notebooks in CI, and preserving the state of the cookbook at each release for posterity.
1946

20-
[nbsphinx documentation]: https://nbsphinx.readthedocs.io/en/0.8.7/subdir/gallery.html

conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = "OpenMM Cookbook"
21-
copyright = "2022, The OpenMM Contributors"
20+
project = "OpenMM Cookbook & Tutorials"
21+
copyright = "2023, The OpenMM Contributors"
2222
author = "The OpenMM Contributors"
2323
release = os.getenv("PAGES_DEPLOY_PATH","dev")
2424
print(release)

cookbook.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
orphan: true
3+
---
4+
# The OpenMM Cookbook
5+
6+
7+
## Getting Started
8+
9+
:::{nbgallery}
10+
---
11+
glob: True
12+
caption: Getting Started
13+
---
14+
notebooks/cookbook/first_simulation.ipynb
15+
16+
:::
17+
18+
## Simulation Protocols
19+
20+
:::{nbgallery}
21+
---
22+
glob: True
23+
caption: Simulation Protocols
24+
---
25+
notebooks/cookbook/Changing Temperature and Pressure
26+
notebooks/cookbook/Saving Systems to XML Files
27+
notebooks/cookbook/Merging Molecules
28+
notebooks/cookbook/Adding Hydrogens to Nonstandard Molecules
29+
:::
30+
31+
## Restraints, Constraints, and External Forces
32+
33+
:::{nbgallery}
34+
---
35+
glob: True
36+
caption: Restraints, Constraints, and External Forces
37+
---
38+
notebooks/cookbook/Applying a Constant External Force
39+
notebooks/cookbook/Constraining Atom Positions
40+
notebooks/cookbook/Restraining Atom Positions
41+
notebooks/cookbook/Restraining Dihedrals
42+
:::
43+
44+
## Analysis and System Inspection
45+
46+
:::{nbgallery}
47+
---
48+
glob: True
49+
caption: Analysis and System Inspection
50+
---
51+
notebooks/cookbook/Analyzing Energy Contributions
52+
notebooks/cookbook/Querying Charges and Other Parameters
53+
:::
54+
55+
56+
----
57+
58+
[Notebooks by Tag](genindex)
59+
60+

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies:
55
- python >= 3.7
66
- pip
77
- sphinx>=4.0.0,<5
8-
- nbsphinx
8+
- nbsphinx<0.9.0 #keep default thumbnails from sphinx_gallery.load_style https://github.com/spatialaudio/nbsphinx/releases/tag/0.9.0
99
- nbformat<5.2 #https://github.com/jupyter/nbformat/issues/303
1010
- pytest
1111
- nbval

index.md

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,20 @@
11
# The OpenMM Cookbook
2+
[Click here for the OpenMM Cookbook](cookbook.md)
23

3-
## Getting Started
4+
The OpenMM Cookbook contains short code examples for common tasks you can perform in OpenMM.
5+
The examples can be run directly in Colab, the runtime is a few seconds for each one.
46

5-
:::{nbgallery}
6-
---
7-
glob: True
8-
caption: Getting Started
9-
---
10-
notebooks/cookbook/first_simulation.ipynb
11-
12-
:::
13-
14-
## Simulation Protocols
15-
16-
:::{nbgallery}
17-
---
18-
glob: True
19-
caption: Simulation Protocols
20-
---
21-
notebooks/cookbook/Changing Temperature and Pressure
22-
notebooks/cookbook/Saving Systems to XML Files
23-
notebooks/cookbook/Merging Molecules
24-
notebooks/cookbook/Adding Hydrogens to Nonstandard Molecules
25-
:::
26-
27-
## Restraints, Constraints, and External Forces
28-
29-
:::{nbgallery}
30-
---
31-
glob: True
32-
caption: Restraints, Constraints, and External Forces
33-
---
34-
notebooks/cookbook/Applying a Constant External Force
35-
notebooks/cookbook/Constraining Atom Positions
36-
notebooks/cookbook/Restraining Atom Positions
37-
notebooks/cookbook/Restraining Dihedrals
38-
:::
39-
40-
## Analysis and System Inspection
41-
42-
:::{nbgallery}
43-
---
44-
glob: True
45-
caption: Analysis and System Inspection
46-
---
47-
notebooks/cookbook/Analyzing Energy Contributions
48-
notebooks/cookbook/Querying Charges and Other Parameters
49-
:::
7+
# The OpenMM Tutorials
8+
[Click here for the OpenMM Tutorials](tutorials.md)
509

51-
## Tutorials
10+
The OpenMM Tutorials are longer examples that walk you through specific simulation methods.
11+
These can also be run in Colab, but due to the longer compute time required (tens of minutes to hours) you may find it better to run them on your own machine.
5212

53-
:::{nbgallery}
13+
:::{toctree}
5414
---
55-
glob: True
56-
caption: Tutorials
15+
hidden: true
16+
maxdepth: 3
5717
---
58-
:::
59-
60-
61-
----
62-
63-
[Notebooks by Tag](genindex)
64-
65-
18+
cookbook.md
19+
tutorials.md
20+
:::

notebooks/cookbook/first_simulation.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
],
6565
"metadata": {
6666
"kernelspec": {
67-
"display_name": "Python 3.9.13 ('openmm')",
67+
"display_name": "Python 3",
6868
"language": "python",
6969
"name": "python3"
7070
},
@@ -78,7 +78,7 @@
7878
"name": "python",
7979
"nbconvert_exporter": "python",
8080
"pygments_lexer": "ipython3",
81-
"version": "3.9.13"
81+
"version": "3.9.6 (default, Sep 26 2022, 11:37:49) \n[Clang 14.0.0 (clang-1400.0.29.202)]"
8282
},
8383
"tags": [
8484
"barostat",
@@ -87,7 +87,7 @@
8787
],
8888
"vscode": {
8989
"interpreter": {
90-
"hash": "16b2d2c1789d035bceb6d775bd7ffc39b805c8f0529038638d98b11c7a85ade5"
90+
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
9191
}
9292
}
9393
},

0 commit comments

Comments
 (0)