Skip to content

Commit ab95477

Browse files
authored
CI (#2)
* Start on CI workflow (incl. binder env) * fix branches; add schedule (7:07 on Sunday) * try to fix action * forgot to make it a list * correct cron * Is this midnight sunday? * cleanup * Add answer patches
1 parent a17c820 commit ab95477

File tree

5 files changed

+236
-0
lines changed

5 files changed

+236
-0
lines changed

.github/workflows/answers_1.patch

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff --git a/1_tps_sampling_tutorial.ipynb b/1_tps_sampling_tutorial.ipynb
2+
index 7814be1..555e20a 100644
3+
--- a/1_tps_sampling_tutorial.ipynb
4+
+++ b/1_tps_sampling_tutorial.ipynb
5+
@@ -191,6 +191,16 @@
6+
"# Figure out which atoms make the dihedral, find their atom indices, then create the CV."
7+
]
8+
},
9+
+ {
10+
+ "cell_type": "code",
11+
+ "execution_count": null,
12+
+ "metadata": {},
13+
+ "outputs": [],
14+
+ "source": [
15+
+ "### ANSWER\n",
16+
+ "psi = paths.MDTrajFunctionCV(\"psi\", md.compute_dihedrals, engine.topology, indices=[[6,8,14,16]])"
17+
+ ]
18+
+ },
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
@@ -232,6 +242,21 @@
23+
"# YOUR TURN: define the `alpha_R` state"
24+
]
25+
},
26+
+ {
27+
+ "cell_type": "code",
28+
+ "execution_count": null,
29+
+ "metadata": {},
30+
+ "outputs": [],
31+
+ "source": [
32+
+ "### ANSWER\n",
33+
+ "alpha_R = (\n",
34+
+ " paths.PeriodicCVDefinedVolume(phi, lambda_min=-180/deg, lambda_max=0/deg, \n",
35+
+ " period_min=-np.pi, period_max=np.pi)\n",
36+
+ " & paths.PeriodicCVDefinedVolume(psi, lambda_min=-100/deg, lambda_max=0/deg,\n",
37+
+ " period_min=-np.pi, period_max=np.pi)\n",
38+
+ ").named(\"alpha_R\")"
39+
+ ]
40+
+ },
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {},

.github/workflows/answers_2.patch

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
diff --git a/2_tps_analysis_tutorial.ipynb b/2_tps_analysis_tutorial.ipynb
2+
index a6ab056..52b6e52 100644
3+
--- a/2_tps_analysis_tutorial.ipynb
4+
+++ b/2_tps_analysis_tutorial.ipynb
5+
@@ -137,9 +127,17 @@
6+
{
7+
"cell_type": "code",
8+
"execution_count": null,
9+
- "metadata": {
10+
- "collapsed": true
11+
- },
12+
+ "metadata": {},
13+
+ "outputs": [],
14+
+ "source": [
15+
+ "### ANSWER \n",
16+
+ "traj = storage.steps[25].active[0].trajectory"
17+
+ ]
18+
+ },
19+
+ {
20+
+ "cell_type": "code",
21+
+ "execution_count": null,
22+
+ "metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"md_traj = traj.to_mdtraj().image_molecules()\n",
26+
@@ -182,9 +178,45 @@
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
- "metadata": {
31+
- "collapsed": true
32+
- },
33+
+ "metadata": {},
34+
+ "outputs": [],
35+
+ "source": [
36+
+ "### ANSWER (1/3)\n",
37+
+ "step = storage.steps[25]\n",
38+
+ "shooting_pt = step.change.canonical.details.shooting_snapshot\n",
39+
+ "sp_as_traj = paths.Trajectory([shooting_pt])"
40+
+ ]
41+
+ },
42+
+ {
43+
+ "cell_type": "code",
44+
+ "execution_count": null,
45+
+ "metadata": {},
46+
+ "outputs": [],
47+
+ "source": [
48+
+ "### ANSWER (2/3)\n",
49+
+ "# visualize using the same approach as above\n",
50+
+ "sp_md_traj = sp_as_traj.to_mdtraj().image_molecules()\n",
51+
+ "sp_view = nv.show_mdtraj(sp_md_traj)\n",
52+
+ "sp_view.add_ball_and_stick(\"ACE ALA NME\")\n",
53+
+ "sp_view.center()\n",
54+
+ "sp_view"
55+
+ ]
56+
+ },
57+
+ {
58+
+ "cell_type": "code",
59+
+ "execution_count": null,
60+
+ "metadata": {},
61+
+ "outputs": [],
62+
+ "source": [
63+
+ "### ANSWER (3/3)\n",
64+
+ "# was the step accepted or rejected?\n",
65+
+ "print(step.change.accepted)"
66+
+ ]
67+
+ },
68+
+ {
69+
+ "cell_type": "code",
70+
+ "execution_count": null,
71+
+ "metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"storage.close()"
75+
@@ -464,9 +474,18 @@
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
- "metadata": {
80+
- "collapsed": true
81+
- },
82+
+ "metadata": {},
83+
+ "outputs": [],
84+
+ "source": [
85+
+ "### ANSWER\n",
86+
+ "trajA = flexible.steps[7700].active[0].trajectory\n",
87+
+ "trajB = flexible.steps[8000].active[0].trajectory"
88+
+ ]
89+
+ },
90+
+ {
91+
+ "cell_type": "code",
92+
+ "execution_count": null,
93+
+ "metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"ax = plotter.plot(xlim=(-np.pi, 0), ylim=(-np.pi/2, np.pi), cmap=\"Blues\")\n",

.github/workflows/answers_3.patch

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/3_committor_analysis_tutorial.ipynb b/3_committor_analysis_tutorial.ipynb
2+
index 449afa4..c7c5b97 100644
3+
--- a/3_committor_analysis_tutorial.ipynb
4+
+++ b/3_committor_analysis_tutorial.ipynb
5+
@@ -174,15 +161,29 @@
6+
{
7+
"cell_type": "code",
8+
"execution_count": null,
9+
- "metadata": {
10+
- "collapsed": true
11+
- },
12+
+ "metadata": {},
13+
"outputs": [],
14+
"source": [
15+
"# YOUR TURN: Do the same for the psi variable.\n",
16+
"# Remember to start by creating a `psi_hash`."
17+
]
18+
},
19+
+ {
20+
+ "cell_type": "code",
21+
+ "execution_count": null,
22+
+ "metadata": {},
23+
+ "outputs": [],
24+
+ "source": [
25+
+ "### ANSWER:\n",
26+
+ "psi_hash = lambda x : float(psi(x))\n",
27+
+ "analyzer.to_pandas(label_function=psi_hash)\n",
28+
+ "hist1D, psi_bins = analyzer.committor_histogram(psi_hash, alpha_R, bins=10)\n",
29+
+ "bin_widths = [psi_bins[i+1]-psi_bins[i] for i in range(len(psi_bins)-1)]\n",
30+
+ "plt.bar(x=psi_bins[:-1], height=hist1D, width=bin_widths)\n",
31+
+ "plt.xlabel(\"$\\psi$\")\n",
32+
+ "plt.ylabel(\"$p_B$\");"
33+
+ ]
34+
+ },
35+
{
36+
"cell_type": "markdown",
37+
"metadata": {},

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Tests"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
#schedule:
11+
#- cron: "0 0 * * 0"
12+
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
17+
jobs:
18+
tests:
19+
runs-on: ubuntu-latest
20+
name: "Test answer key"
21+
strategy:
22+
matrix:
23+
CONDA_PY: [3.7]
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-python@v2
28+
- uses: conda-incubator/setup-miniconda@v2
29+
with:
30+
auto-update-conda: true
31+
python-version: ${{ matrix.CONDA_PY }}
32+
environment-file: binder/environment.yml
33+
activate-environment: ops-tutorial
34+
- name: "Install testing tools"
35+
run: python -m pip install pytest nbval
36+
- name: "Conda info"
37+
run: |
38+
conda info
39+
conda list
40+
- name: "Patch answers"
41+
run: |
42+
patch < .github/workflows/answers_1.patch
43+
patch < .github/workflows/answers_2.patch
44+
patch < .github/workflows/answers_3.patch
45+
- name: "Run tests"
46+
run: |
47+
pytest --nbval-lax 1_tps_sampling_tutorial.ipynb

binder/environment.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: ops-tutorial
2+
channels:
3+
- conda-forge
4+
- omnia
5+
- defaults
6+
dependencies:
7+
- jupyter
8+
- nglview
9+
- openmm
10+
- tqdm
11+
- openpathsampling
12+
- openmmtools
13+
prefix: /Users/dwhs/miniconda3/envs/ops-tutorial

0 commit comments

Comments
 (0)