Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make refresh notebook still commit successful notebooks on fail #313

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 10 additions & 1 deletion script/make_utils/jupyter.sh
Original file line number Diff line number Diff line change
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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what makes the refresh notebook not crash on failure @RomanBredehoft .

TIME_EXEC=$((END-START))
print_time_execution "${NOTEBOOK}" ${TIME_EXEC}
Expand Down
Loading