Skip to content

Commit

Permalink
chore: make refresh notebook still commit successful notebooks on fai…
Browse files Browse the repository at this point in the history
…lure
  • Loading branch information
jfrery committed Oct 3, 2023
1 parent f46a112 commit 44e0e0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/refresh-notebooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ jobs:
run: |
make jupyter_execute
- name: Prepare PR Body
run: |
SUCCESSFUL_NOTEBOOKS=$(cat ./successful_notebooks.txt | tr '\n' ' ' | sed 's/ /\\n- /g')
FAILED_NOTEBOOKS=$(cat ./failed_notebooks.txt | tr '\n' ' ' | sed 's/ /\\n- /g')
PR_BODY="Automatic PR with notebook refresh for ${{ github.ref_name }}.\\n"
PR_BODY+="## Successful Notebooks\\n- $SUCCESSFUL_NOTEBOOKS\\n"
PR_BODY+="## Failed Notebooks\\n- $FAILED_NOTEBOOKS"
echo "PR_BODY=${PR_BODY}" >> "$GITHUB_ENV"
- name: Open PR
uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666
with:
Expand All @@ -97,11 +106,10 @@ jobs:
branch: "refresh-notebooks-for-${{ github.ref_name }}"
base: "${{ github.ref_name }}"
title: "Refresh notebooks for ${{ github.ref_name }}"
body: "Automatic PR with notebooks refresh for ${{ github.ref_name }}."
body: ${{ env.PR_BODY }}
add-paths: |
docs/**/*.ipynb
stop-runner-linux:
name: Stop EC2 runner
needs: [refresh-notebooks, start-runner-linux]
Expand Down
13 changes: 11 additions & 2 deletions script/make_utils/jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WHAT_TO_DO="open"

# Create a list of notebooks with long execution times in order not to consider them when refreshing
# all notebooks at the same time.
LONG_EXECUTION_TIMES_NOTEBOOKS=()
LONG_EXECUTION_TIMES_NOTEBOOKS=("ClassifierComparison.ipynb")

while [ -n "$1" ]
do
Expand Down Expand Up @@ -57,6 +57,11 @@ elif [ "$WHAT_TO_DO" == "run_all_notebooks" ]
then
echo "Refreshing notebooks"

SUCCESSFUL_NOTEBOOKS="./successful_notebooks.txt"
FAILED_NOTEBOOKS="./failed_notebooks.txt"
echo "" > "${SUCCESSFUL_NOTEBOOKS}"
echo "" > "${FAILED_NOTEBOOKS}"

# shellcheck disable=SC2207
LIST_OF_NOTEBOOKS=($(find ./docs/ -type f -name "*.ipynb" | grep -v ".nbconvert" | grep -v "_build" | grep -v "ipynb_checkpoints"))

Expand All @@ -75,7 +80,11 @@ then
echo "Refreshing ${NOTEBOOK}"

START=$(date +%s)
jupyter nbconvert --to notebook --inplace --execute "${NOTEBOOK}"
if jupyter nbconvert --to notebook --inplace --execute "${NOTEBOOK}"; then
echo "${NOTEBOOK}" >> "${SUCCESSFUL_NOTEBOOKS}"
else
echo "${NOTEBOOK}" >> "${FAILED_NOTEBOOKS}"
fi
END=$(date +%s)
TIME_EXEC=$((END-START))
print_time_execution "${NOTEBOOK}" ${TIME_EXEC}
Expand Down

0 comments on commit 44e0e0e

Please sign in to comment.