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

Run the cube notebook on PR #1972

Merged
merged 7 commits into from
Apr 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -44,9 +44,19 @@ jobs:
UPLOAD_COMMIT_OVERRIDE: ${{ github.event.pull_request.head.sha }}
secrets: inherit

run-notebook:
name: 'Run Notebook'
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

save-pr-summary:
name: 'Save PR Summary'
needs: [upload-web]
needs: [upload-web, run-notebook]
uses: ./.github/workflows/reusable_pr_summary.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/reusable_run_notebook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Reusable Buld and Upload Notebook

on:
workflow_call:
inputs:
CONCURRENCY:
required: true
type: string
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: ''

concurrency:
group: ${{ inputs.CONCURRENCY }}-run-notebook
cancel-in-progress: true

jobs:

run-notebook:
name: Run notebook

permissions:
contents: "read"
id-token: "write"

runs-on: ubuntu-latest

container:
image: rerunio/ci_docker:0.6

steps:
- uses: actions/checkout@v3

- 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
7 changes: 7 additions & 0 deletions scripts/generate_pr_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
14 changes: 14 additions & 0 deletions scripts/templates/pr_results_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
margin-left: 20px;
}

.notebook-list {
margin-left: 20px;
}

.wheel-list {
margin-left: 20px;
}
Expand All @@ -34,6 +38,16 @@ <h3>Hosted App:</h3>
{% if build.bench_results %}
<h3><a href="{{ build.bench_results }}" target="_blank">Benchmark Results</a></h3>
{% endif %}
{% if build.notebooks %}
<div class="notebook-list">
<h3>Notebooks:</h3>
<ul>
{% for notebook in build.notebooks %}
<li><a href="{{ notebook }}" target="_blank">{{ notebook.split('/')[-1] }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if build.wheels %}
<div class="wheel-list">
<h3>Wheels:</h3>
Expand Down