Skip to content

Commit

Permalink
Merge pull request #131 from pyiron/pass-kernelname
Browse files Browse the repository at this point in the history
[patch] optionally pass kernel to papermill (headless notebook execution)
  • Loading branch information
mbruns91 authored Sep 4, 2024
2 parents 9e97c10 + 8e21260 commit 72012de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/push-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ on:
description: 'The directory containing the tests run with the alternate environment'
default: tests
required: false
notebooks-kernel:
type: string
description: 'Name of the kernel to be used by papermill during headless execution'
default: python3
required: false


jobs:
Expand Down Expand Up @@ -229,7 +234,7 @@ jobs:
python-version: ${{ inputs.python-version }}
env-files: ${{ inputs.notebooks-env-files }}
exclusion-file: ${{ inputs.notebooks-exclusion-file }}

kernel: ${{ inputs.notebooks-kernel }}

unit-tests:
needs: commit-updated-env
Expand Down
10 changes: 8 additions & 2 deletions .support/build_notebooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

NOTEBOOKS_DIR=$1
EXCLUSION_FILE=$2
KERNEL=$3

# Remove excluded notebooks
if [ ${EXCLUSION_FILE} != "" ]; then
if [ "${EXCLUSION_FILE}" != "" ]; then
for f in $(cat ${EXCLUSION_FILE}); do
rm "${NOTEBOOKS_DIR}/$f";
done;
fi

# Set the kernel to be used by papermill to 'python3' if not specified otherwise
if [ "${KERNEL}" = "" ]; then
KERNEL=python3;
fi

# execute notebooks
i=0;
for notebook in $(find ${NOTEBOOKS_DIR} -type f -name '*.ipynb'); do
papermill ${notebook} ${notebook%.*}-out.${notebook##*.} || i=$((i+1));
papermill ${notebook} ${notebook%.*}-out.${notebook##*.} -k ${KERNEL} || i=$((i+1));
done;

# push error to next level
Expand Down
6 changes: 5 additions & 1 deletion build-notebooks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
exclusion-file:
description: 'An optional path to a file containing the names of notebooks to NOT build'
required: false
kernel:
description: 'Name of the kernel to be used by papermill during headless execution'
default: python3
required: false

runs:
using: 'composite'
Expand All @@ -31,4 +35,4 @@ runs:
- uses: pyiron/actions/pyiron-config@main
- name: Build notebooks
shell: bash -l {0}
run: $GITHUB_ACTION_PATH/../.support/build_notebooks.sh ${{ inputs.notebooks-dir }} ${{ inputs.exclusion-file }}
run: $GITHUB_ACTION_PATH/../.support/build_notebooks.sh ${{ inputs.notebooks-dir }} ${{ inputs.exclusion-file }} ${{ inputs.kernel }}

0 comments on commit 72012de

Please sign in to comment.