From 44e0e0e4d531557b863ed22eb9aa7a98af16e16e Mon Sep 17 00:00:00 2001 From: jfrery Date: Fri, 29 Sep 2023 12:15:29 +0200 Subject: [PATCH 1/2] chore: make refresh notebook still commit successful notebooks on failure --- .github/workflows/refresh-notebooks.yaml | 12 ++++++++++-- script/make_utils/jupyter.sh | 13 +++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/refresh-notebooks.yaml b/.github/workflows/refresh-notebooks.yaml index ea30f0f84..3bef93156 100644 --- a/.github/workflows/refresh-notebooks.yaml +++ b/.github/workflows/refresh-notebooks.yaml @@ -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: @@ -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] diff --git a/script/make_utils/jupyter.sh b/script/make_utils/jupyter.sh index 3a9a04028..33f252784 100755 --- a/script/make_utils/jupyter.sh +++ b/script/make_utils/jupyter.sh @@ -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 @@ -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")) @@ -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} From d5ceec9be7c16c3a792cf330037b8ec470a7b121 Mon Sep 17 00:00:00 2001 From: jfrery Date: Tue, 3 Oct 2023 10:34:33 +0200 Subject: [PATCH 2/2] chore: add back classifier comparison --- script/make_utils/jupyter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/make_utils/jupyter.sh b/script/make_utils/jupyter.sh index 33f252784..a3e4475ab 100755 --- a/script/make_utils/jupyter.sh +++ b/script/make_utils/jupyter.sh @@ -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=("ClassifierComparison.ipynb") +LONG_EXECUTION_TIMES_NOTEBOOKS=() while [ -n "$1" ] do