From cdce6a2e3d6853bbd9debb2a700e946c48316fab Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 26 Apr 2023 03:50:51 +0200 Subject: [PATCH 1/5] Run the cube notebook on PR --- .github/workflows/on_pull_request.yml | 16 ++++- .github/workflows/reusable_run_notebook.yml | 73 +++++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/reusable_run_notebook.yml diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index 4da87faf76bb..6bddc61268df 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -23,7 +23,7 @@ jobs: SAVE_CACHE: false PLATFORM: linux MATURIN_FEATURE_FLAGS: '--no-default-features --features extension-module' - WHEEL_ARTIFACT_NAME: '' # the min-test wheel isn't used for anything + WHEEL_ARTIFACT_NAME: 'linux-wheel-fast' RRD_ARTIFACT_NAME: linux-rrd-fast secrets: inherit concurrency: @@ -50,9 +50,21 @@ jobs: group: pr-upload-web-${{ github.event.pull_request.number }} cancel-in-progress: true + run-notebook: + name: 'Run Notebook' + needs: [min-test-wheel] + uses: ./.github/workflows/reusable_run_notebook.yml + with: + WHEEL_ARTIFACT_NAME: linux-wheel-fast + UPLOAD_COMMIT_OVERRIDE: ${{ github.event.pull_request.head.sha }} + secrets: inherit + concurrency: + group: pr-run-notebook-${{ github.event.pull_request.number }} + cancel-in-progress: true + save-pr-summary: name: 'Save PR Summary' - needs: [upload-web] + needs: [upload-web, run-notebook] uses: ./.github/workflows/reusable_pr_summary.yml with: PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/reusable_run_notebook.yml b/.github/workflows/reusable_run_notebook.yml new file mode 100644 index 000000000000..1175db90422d --- /dev/null +++ b/.github/workflows/reusable_run_notebook.yml @@ -0,0 +1,73 @@ +name: Reusable Buld and Upload Notebook + +on: + workflow_call: + inputs: + WHEEL_ARTIFACT_NAME: + required: false + type: string + default: '' + # We need this because PRs use a merged commit but we really want + # to track uploads based on the source commit. + UPLOAD_COMMIT_OVERRIDE: + required: false + type: string + default: '' + +jobs: + + run-notebook: + name: Run notebook + + permissions: + contents: "read" + id-token: "write" + + runs-on: ubuntu-latest + + container: + image: rerunio/ci_docker:0.6 + + steps: + - name: Download Wheel + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.WHEEL_ARTIFACT_NAME }} + path: wheel + + - name: Install built wheel + shell: bash + run: | + pip install --find-links wheel rerun-sdk + + - name: Install Deps + shell: bash + run: | + pip install -r examples/python/notebook/requirements.txt + + - name: Create notebook + shell: bash + run: | + jupyter nbconvert --to=html --ExecutePreprocessor.enabled=True examples/python/notebook/cube.ipynb --output /tmp/cube.html + + - id: "auth" + uses: google-github-actions/auth@v1 + with: + workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} + + - name: Add SHORT_SHA env property with commit short sha + run: | + if [ -z "${{ inputs.UPLOAD_COMMIT_OVERRIDE }}" ]; then + USED_SHA=${{ github.sha }} + else + USED_SHA=${{ inputs.UPLOAD_COMMIT_OVERRIDE }} + fi + echo "SHORT_SHA=$(echo $USED_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: "Upload Notebook" + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "/tmp/cube.html" + destination: "rerun-builds/commit/${{env.SHORT_SHA}}/notebooks" + parent: false From 91e7f75c2e801d4ce5c8f1adc925854cedae6f8f Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 26 Apr 2023 04:06:40 +0200 Subject: [PATCH 2/5] Need to checkout code to run notebook --- .github/workflows/reusable_run_notebook.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable_run_notebook.yml b/.github/workflows/reusable_run_notebook.yml index 1175db90422d..0c668dc35d07 100644 --- a/.github/workflows/reusable_run_notebook.yml +++ b/.github/workflows/reusable_run_notebook.yml @@ -29,6 +29,8 @@ jobs: image: rerunio/ci_docker:0.6 steps: + - uses: actions/checkout@v3 + - name: Download Wheel uses: actions/download-artifact@v3 with: From 8d6a01990efa5dcc948a640675e653f47abc54b8 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 26 Apr 2023 04:06:56 +0200 Subject: [PATCH 3/5] Add notebooks to the build summary --- scripts/generate_pr_summary.py | 7 +++++++ scripts/templates/pr_results_summary.html | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/scripts/generate_pr_summary.py b/scripts/generate_pr_summary.py index 4043be33c40f..74fe056a4340 100644 --- a/scripts/generate_pr_summary.py +++ b/scripts/generate_pr_summary.py @@ -54,6 +54,13 @@ def generate_pr_summary(github_token: str, github_repository: str, pr_number: in print("Found benchmark results: {}".format(commit_short)) found["bench_results"] = f"https://build.rerun.io/{bench_blob.name}" + # Check if there are notebook results + notebook_blobs = list(builds_bucket.list_blobs(prefix=f"commit/{commit_short}/notebooks")) + notebooks = [f"https://build.rerun.io/{blob.name}" for blob in notebook_blobs if blob.name.endswith(".html")] + if notebooks: + print("Found notebooks for commit: {}".format(commit_short)) + found["notebooks"] = notebooks + # Get the wheel files for the commit wheel_blobs = list(builds_bucket.list_blobs(prefix=f"commit/{commit_short}/wheels")) wheels = [f"https://build.rerun.io/{blob.name}" for blob in wheel_blobs if blob.name.endswith(".whl")] diff --git a/scripts/templates/pr_results_summary.html b/scripts/templates/pr_results_summary.html index 5990b71e5134..7cccb4ac3f14 100644 --- a/scripts/templates/pr_results_summary.html +++ b/scripts/templates/pr_results_summary.html @@ -12,6 +12,10 @@ margin-left: 20px; } + .notebook-list { + margin-left: 20px; + } + .wheel-list { margin-left: 20px; } @@ -34,6 +38,16 @@

Hosted App:

{% if build.bench_results %}

Benchmark Results

{% endif %} + {% if build.notebooks %} +
+

Notebooks:

+ +
+ {% endif %} {% if build.wheels %}

Wheels:

From f172b9ecb543fbd9d96213117c735de41a8f6131 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 26 Apr 2023 04:52:43 +0200 Subject: [PATCH 4/5] Fix template --- scripts/templates/pr_results_summary.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/templates/pr_results_summary.html b/scripts/templates/pr_results_summary.html index 7cccb4ac3f14..542171ad6635 100644 --- a/scripts/templates/pr_results_summary.html +++ b/scripts/templates/pr_results_summary.html @@ -42,7 +42,7 @@

Benchmark Results

Notebooks:

From 275687cfb0d08207097b85af9a1313faff946579 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 26 Apr 2023 05:38:36 +0200 Subject: [PATCH 5/5] Use the new concurrency model --- .github/workflows/on_pull_request.yml | 4 +--- .github/workflows/reusable_run_notebook.yml | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index 85a60f60be53..7f1425a538ab 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -49,12 +49,10 @@ jobs: needs: [min-test-wheel] uses: ./.github/workflows/reusable_run_notebook.yml with: + CONCURRENCY: pr-${{ github.event.pull_request.number }} WHEEL_ARTIFACT_NAME: linux-wheel-fast UPLOAD_COMMIT_OVERRIDE: ${{ github.event.pull_request.head.sha }} secrets: inherit - concurrency: - group: pr-run-notebook-${{ github.event.pull_request.number }} - cancel-in-progress: true save-pr-summary: name: 'Save PR Summary' diff --git a/.github/workflows/reusable_run_notebook.yml b/.github/workflows/reusable_run_notebook.yml index 0c668dc35d07..c2ccd4377316 100644 --- a/.github/workflows/reusable_run_notebook.yml +++ b/.github/workflows/reusable_run_notebook.yml @@ -3,6 +3,9 @@ name: Reusable Buld and Upload Notebook on: workflow_call: inputs: + CONCURRENCY: + required: true + type: string WHEEL_ARTIFACT_NAME: required: false type: string @@ -14,6 +17,10 @@ on: type: string default: '' +concurrency: + group: ${{ inputs.CONCURRENCY }}-run-notebook + cancel-in-progress: true + jobs: run-notebook: