Skip to content

Commit 835c13c

Browse files
committed
fix(bash): fix run_notebooks.sh (used file from pydesrap_mms)
1 parent de8e6bd commit 835c13c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

run_notebooks.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
#!/usr/bin/env bash
22

3-
# Loop through all notebooks in the specified directory
4-
for nb in notebooks/*.ipynb; do
3+
# Get the conda environment's jupyter path
4+
CONDA_JUPYTER=$(dirname "$(which python)")/jupyter
5+
6+
run_notebook() {
7+
local nb="$1"
58
echo "🏃 Running notebook: $nb"
6-
7-
# Execute and update the notebook in-place
8-
# With some processing to remove metadata created by nbconvert
9-
if python -m jupyter nbconvert --to notebook --inplace --execute \
9+
if "${CONDA_JUPYTER}" nbconvert --to notebook --inplace --execute \
1010
--ClearMetadataPreprocessor.enabled=True \
1111
--ClearMetadataPreprocessor.clear_notebook_metadata=False \
1212
--ClearMetadataPreprocessor.preserve_cell_metadata_mask="kernelspec" \
13-
"$nb"; then
13+
"$nb"
14+
then
1415
echo "✅ Successfully processed: $nb"
1516
else
1617
echo "❌ Error processing: $nb"
1718
fi
18-
1919
echo "-------------------------"
20-
done
20+
}
21+
22+
if [[ -n "$1" ]]; then
23+
run_notebook "$1"
24+
else
25+
for nb in notebooks/*.ipynb; do
26+
run_notebook "$nb"
27+
done
28+
fi

0 commit comments

Comments
 (0)