Skip to content

Commit 7960d12

Browse files
author
Han Lin Mai
committed
Enhance notebook build process by adding error handling and logging; update environment.yml with specific package versions and dependencies; improve dataset import script to check for existing directories and files.
1 parent 193a921 commit 7960d12

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
11
#!/bin/bash
2+
set -e # Exit on any error
3+
4+
echo "Starting notebook build process..."
5+
26
# pyiron config
7+
echo "Setting up pyiron configuration..."
38
python .github/ci_support/pyironconfig.py
49

510
# import dataset
11+
echo "Importing datasets..."
612
bash .github/ci_support/import_dataset.sh
713

8-
# install papermill (already in environment.yml)
9-
# conda install -c conda-forge papermill
10-
1114
# register jupyter kernel
15+
echo "Registering Jupyter kernel..."
1216
python -m ipykernel install --user --name python3 --display-name "Python 3"
1317

18+
# verify papermill is available
19+
echo "Verifying papermill installation..."
20+
python -c "import papermill; print('papermill version:', papermill.__version__)"
21+
1422
# execute notebooks
23+
echo "Executing notebooks..."
1524
current_dir=$(pwd)
1625
i=0;
1726
for f in $(find . -name "*.ipynb" | sort -n); do
27+
echo "Processing notebook: $f"
1828
cd $(dirname $f);
1929
notebook=$(basename $f);
20-
papermill ${notebook} ${notebook%.*}-out.${notebook##*.} -k "python3" || i=$((i+1));
30+
if papermill ${notebook} ${notebook%.*}-out.${notebook##*.} -k "python3"; then
31+
echo "Successfully executed: $notebook"
32+
else
33+
echo "Failed to execute: $notebook"
34+
i=$((i+1));
35+
fi
2136
cd $current_dir;
2237
done;
2338

2439
# push error to next level
2540
if [ $i -gt 0 ]; then
41+
echo "Failed to execute $i notebook(s)"
2642
exit 1;
2743
fi;
44+
45+
echo "All notebooks executed successfully!"

.github/ci_support/environment.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
channels:
22
- conda-forge
33
dependencies:
4+
- python>=3.11,<3.13
5+
- pip
6+
- numpy =1.26.4
7+
- ase =3.26.0
8+
- pymatgen =2025.6.14
9+
- pyiron_workflow =0.15.2
10+
- pyiron_lammps =0.4.6
11+
- pandas =2.3.1
12+
- lammps =2024.08.29=*_mpi*
13+
- pysqa =0.3.0
414
- jupyter-book
515
- ipykernel
616
- jupyter
717
- papermill
8-
18+
- pip:
19+
- pyiron-workflow-atomistics==0.0.2
20+
- pyiron-workflow-lammps==0.0.2
21+
- pyiron-snippets==0.2.0

.github/ci_support/import_dataset.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
#!/bin/bash
2+
# Check if pyiron directory exists, if not create it
3+
if [ ! -d "pyiron" ]; then
4+
echo "Creating pyiron directory..."
5+
mkdir -p pyiron/calculation
6+
fi
7+
28
cd pyiron
9+
10+
# Check if calculation directory and tar.gz files exist
11+
if [ ! -d "calculation" ] || [ ! "$(ls -A calculation/*.tar.gz 2>/dev/null)" ]; then
12+
echo "No calculation/*.tar.gz files found. Skipping dataset import."
13+
exit 0
14+
fi
15+
316
for ds in $(ls calculation/*.tar.gz); do
417
cp ${ds} .
518
cp calculation/export.csv .

.github/workflows/notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
auto-update-conda: true
1919
python-version: 3.12
20-
environment-file: environment.yml
20+
environment-file: .github/ci_support/environment.yml
2121
auto-activate-base: false
2222
- name: Tests
2323
shell: bash -l {0}

0 commit comments

Comments
 (0)