Skip to content

Commit b6039d6

Browse files
author
Shyam D
committed
Merge branch 'master' into ardunn-master
# Conflicts: # requirements.txt # workshop/lessons/08_ml_matminer/matminer-notes.ipynb
2 parents a264a61 + 8fb187f commit b6039d6

File tree

18 files changed

+650
-3292
lines changed

18 files changed

+650
-3292
lines changed

.github/run_notebooks.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
""" Python script to run notebooks in the directory they exist in """
2+
import os
3+
4+
import nbformat
5+
import yaml
6+
from nbclient import NotebookClient
7+
from nbclient.exceptions import CellExecutionError
8+
9+
10+
def recursive_get(items):
11+
if isinstance(items, dict):
12+
for v in items.values():
13+
yield from recursive_get(v)
14+
elif isinstance(items, list):
15+
for v in items:
16+
yield from recursive_get(v)
17+
else:
18+
yield items
19+
20+
21+
with open("mkdocs.yml") as f:
22+
mkdocs_config = yaml.load(f)
23+
24+
notebooks = [
25+
item
26+
for item in recursive_get(mkdocs_config.get("nav", {}))
27+
if item.endswith(".ipynb")
28+
]
29+
30+
os.chdir("workshop")
31+
for notebook in notebooks:
32+
print(f"Loading {notebook}")
33+
nb = nbformat.read(notebook, as_version=4)
34+
35+
for cell in nb.cells:
36+
if cell.get("cell_type", "") == "code" and "no-execute" in cell.get(
37+
"metadata", {}
38+
).get("tags", []):
39+
cell["cell_type"] = "markdown"
40+
41+
client = NotebookClient(
42+
nb,
43+
timeout=600,
44+
resources={"metadata": {"path": os.path.dirname(notebook)}},
45+
)
46+
try:
47+
client.execute()
48+
nbformat.write(nb, notebook)
49+
except CellExecutionError:
50+
msg = 'Error executing the notebook "%s".\n\n' % notebook
51+
print(msg)
52+
raise
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Merge me!
22

33
on:
4-
check_suite:
4+
workflow_run:
55
types:
66
- completed
7+
workflows:
8+
# List all required workflow names here.
9+
- 'testing'
710

811
jobs:
912
merge-me:
@@ -13,4 +16,4 @@ jobs:
1316
- name: Merge me!
1417
uses: ridedott/merge-me-action@v2
1518
with:
16-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/testing.yml

+16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ jobs:
6767
- name: Install workshop package
6868
run: pip install -e .
6969

70+
- name: Install workshop data
71+
run: python ./binder/populate_nobel_database.py
72+
73+
- name: Run Notebooks
74+
env:
75+
PMG_MAPI_KEY: ${{ secrets.MAPI_KEY }}
76+
run: python .github/run_notebooks.py
77+
7078
- name: Build
7179
run: mkdocs build
7280

@@ -105,6 +113,14 @@ jobs:
105113
- name: Install workshop package
106114
run: pip install -e .
107115

116+
- name: Install workshop data
117+
run: python ./binder/populate_nobel_database.py
118+
119+
- name: Run Notebooks
120+
env:
121+
PMG_MAPI_KEY: ${{ secrets.MAPI_KEY }}
122+
run: python .github/run_notebooks.py
123+
108124
- name: Build
109125
run: mkdocs build
110126

binder/apt.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ vim
22
graphviz
33
mongodb
44
gfortran
5-
zip
5+
zip

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ copyright: Built by The Materials Project
44
site_url: https://workshop.materialsproject.org
55
repo_url: https://github.com/materialsproject/workshop
66
docs_dir: workshop
7-
extra_css:
7+
extra_css:
88
- assets/workshop.css
99
extra_javascript:
1010
- assets/config.js

python_module/mp_workshop/fireworks_config/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232

3333
dumpfn(fw_config, fw_config_dir / "FW_config.yaml")
3434
dumpfn(
35-
fworker, fw_config_dir / "my_fworker.yaml", indent=4, default_flow_style=False,
35+
fworker,
36+
fw_config_dir / "my_fworker.yaml",
37+
indent=4,
38+
default_flow_style=False,
3639
)
3740

3841

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pymongo==3.12.0
77
robocrys==0.2.7
88
crystal-toolkit==2021.4.29
99
matminer==0.7.3
10+
ipywidgets==7.5.1
1011
mpcontribs-client==3.12.0
1112
graphviz==0.17
12-
mp-api==0.5.1
13+
mp-api==0.5.1

workshop/assets/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ window.MathJax = {
99
ignoreHtmlClass: ".*|",
1010
processHtmlClass: "arithmatex"
1111
}
12-
};
12+
};

0 commit comments

Comments
 (0)