Skip to content

Commit

Permalink
feat: set a timeout for each cell
Browse files Browse the repository at this point in the history
  • Loading branch information
tueda committed Aug 13, 2024
1 parent 7cfb659 commit 0644f39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/run-tutorial-notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
required: false
default: ''
type: string
timeout:
description: Timeout per cell in seconds
required: false
default: 3600
type: number

jobs:
run:
Expand Down Expand Up @@ -60,7 +65,7 @@ jobs:
-v $(pwd)/madminer_shared:/home/shared
-v $(pwd)/.github/workflows/scripts/run-tutorial-notebook.sh:/tmp/run-tutorial-notebook.sh:ro
madminer-jupyter-env:latest
/tmp/run-tutorial-notebook.sh /home/shared/madminer/${{ inputs.working-directory }} ${{ inputs.notebook }}
/tmp/run-tutorial-notebook.sh /home/shared/madminer/${{ inputs.working-directory }} ${{ inputs.notebook }} ${{ inputs.timeout }}
- name: Upload notebook and logs
uses: actions/upload-artifact@v4
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/scripts/run-tutorial-notebook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eu

working_directory=$1
notebook_file=$2
timeout=$3

if [ ! -f /.dockerenv ]; then
echo 'error: this script must be executed within a container' >&2
Expand All @@ -22,4 +23,10 @@ time {
echo "::endgroup::"

cd "$working_directory"
papermill "$notebook_file" "$notebook_file"
# We may set a timeout (for each cell) to ensure in-progress notebooks and logs are saved,
# even if the workflow hits the total 6-hour limit in GitHub Actions.
if [ "$timeout" -ne 0 ]; then
papermill --execution-timeout "$timeout" "$notebook_file" "$timeout"
else
papermill "$notebook_file" "$timeout"
fi

0 comments on commit 0644f39

Please sign in to comment.