diff --git a/.github/workflows/deployer.yml b/.github/workflows/deployer.yml index a72bc6787..4e27debe5 100644 --- a/.github/workflows/deployer.yml +++ b/.github/workflows/deployer.yml @@ -7,6 +7,47 @@ on: jobs: + tutorials: ################################################################# + runs-on: ubuntu-latest + env: + TUTORIAL_TIMEOUT: 1200s + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip .[tutorial] black[jupyter] + + - name: Setup FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v2 + + - name: Run formatter + run: black tutorials/ + + - name: Export tutorials to .html + run: | + set -x + for file in $(find tutorials -type f -name "*.ipynb"); do + filename=$(basename $file) + htmlfilename="${filename%.ipynb}.html" + htmldir="docs/source"/$(dirname $file) + mkdir -p $htmldir + timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir + break + done + set +x + + - name: Remove unwanted files + run: | + rm -rf build/ tutorials/tutorial4/data/ + + - name: Upload tutorials artifact + uses: actions/upload-artifact@v4 + with: + name: tutorials + path: | + docs/source/tutorials/**/*.html + docs: ####################################################################### runs-on: ubuntu-latest steps: diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml index d4a182f64..35b2e9f2e 100644 --- a/.github/workflows/tester.yml +++ b/.github/workflows/tester.yml @@ -48,6 +48,16 @@ jobs: - name: Install Python dependencies run: python3 -m pip install .[doc] + - name: Create placeholder tutorial HTMLs + run: | + set -e + for nb in tutorials/*.ipynb; do + nbname=$(basename "$nb" .ipynb) + html_dir="docs/source/tutorials/$nbname" + mkdir -p "$html_dir" + echo "

Placeholder for $nbname

This tutorial will be generated by the export workflow.

" > "$html_dir/tutorial.html" + done + - name: Build Documentation run: | make html SPHINXOPTS+='-W' diff --git a/.github/workflows/tutorial_dynamical_tester.yml b/.github/workflows/tutorial_dynamical_tester.yml new file mode 100644 index 000000000..fe0f35307 --- /dev/null +++ b/.github/workflows/tutorial_dynamical_tester.yml @@ -0,0 +1,40 @@ +name: "Testing Tutorials RUn" + +on: + workflow_dispatch: + schedule: + - cron: '20 2 1 * *' + +jobs: + # run on push + test_tutorials: + runs-on: ubuntu-latest + env: + TUTORIAL_TIMEOUT: 1200s + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip .[tutorial] black[jupyter] + + - name: Setup FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v2 + + - name: Run formatter (check only) + run: black --check tutorials/ + + - name: Execute all tutorials + run: | + set -euo pipefail + for file in $(find tutorials -type f -name "*.ipynb"); do + echo "Running tutorial: $file" + timeout --signal=SIGKILL $TUTORIAL_TIMEOUT \ + python -Xfrozen_modules=off -m jupyter nbconvert \ + --execute --to notebook --inplace $file + done \ No newline at end of file diff --git a/.github/workflows/tutorial_exporter.yml b/.github/workflows/tutorial_exporter.yml index 957c9b52c..ddd6705bd 100644 --- a/.github/workflows/tutorial_exporter.yml +++ b/.github/workflows/tutorial_exporter.yml @@ -1,140 +1,114 @@ -name: "Export Tutorials" +name: "Export Tutorial on Comment" on: - workflow_dispatch: - push: - branches: - - "dev" - - "master" - paths: - - 'tutorials/**/*.ipynb' + issue_comment: + types: [created] jobs: - # run on push - export_tutorials_on_push: - if: ${{ github.event_name == 'push' }} - permissions: write-all + export_on_comment: + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/tutorial-exporter') runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read env: TUTORIAL_TIMEOUT: 1200s + steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Install dependencies - run: | - # Dependencies for tutorials - python3 -m pip install --upgrade pip .[tutorial] black[jupyter] - - name: Setup FFmpeg - uses: FedericoCarboni/setup-ffmpeg@v2 - - - id: files - uses: jitterbit/get-changed-files@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - format: space-delimited - - - name: Configure git - run: | - git config user.name "github-actions[bot]" - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - - - name: Run formatter - run: black tutorials/ - - - name: Export tutorials to .py and .html - run: | - set -x - for file in ${{ steps.files.outputs.all }}; do - if [[ $file == *.ipynb ]]; then - filename=$(basename $file) - pyfilename=$(echo ${filename%?????})py - timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file) - htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html - htmldir="docs/source"/$(echo ${file%??????????????} | sed -e 's/-//g') - timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir + # Detect PR branch from comment + - name: Get PR branch from comment + uses: xt0rted/pull-request-comment-branch@v1 + id: comment-branch + + - name: Set latest commit status as pending + uses: myrotvorets/set-commit-status-action@master + with: + sha: ${{ steps.comment-branch.outputs.head_sha }} + token: ${{ secrets.GITHUB_TOKEN }} + status: pending + + # Checkout the PR branch + - name: Checkout PR branch ${{ steps.comment-branch.outputs.head_ref }} + uses: actions/checkout@v3 + with: + ref: ${{ steps.comment-branch.outputs.head_ref }} + + # Setup Python + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.10 + + # Install dependencies + - name: Install dependencies + run: python3 -m pip install --upgrade pip .[tutorial] black[jupyter] + + # Setup FFmpeg (if needed) + - name: Setup FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v2 + + # Format notebooks + - name: Run formatter + run: black tutorials/ + + # Export the tutorial to .py + - name: Export tutorial to .py + run: | + set -euo pipefail + COMMENT_BODY="${{ github.event.comment.body }}" + TUTORIAL_NUM=$(echo "$COMMENT_BODY" | awk '{print $2}') + FILE="tutorials/tutorial${TUTORIAL_NUM}.ipynb" + + if [[ -f "$FILE" ]]; then + echo "Exporting $FILE" + PYFILENAME="${FILE%.ipynb}.py" + timeout --signal=SIGKILL $TUTORIAL_TIMEOUT \ + python -Xfrozen_modules=off -m jupyter nbconvert \ + "$FILE" --to python --output "$PYFILENAME" --output-dir=$(dirname "$FILE") + else + echo "Tutorial $TUTORIAL_NUM not found: $FILE" + exit 1 fi - done - set +x - - - uses: benjlevesque/short-sha@v2.1 - id: short-sha - - - name: Remove unwanted files - run: | - rm -rf build/ tutorials/tutorial4/data/ - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5.0.2 - with: - labels: maintenance - title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }} - branch: export-tutorial-${{ steps.short-sha.outputs.sha }} - base: ${{ github.head_ref }} - commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }} - delete-branch: true - - # run on workflow_dispatch - export_tutorials_workflow_dispatch: - if: ${{ github.event_name == 'workflow_dispatch' }} - permissions: write-all - runs-on: ubuntu-latest - env: - TUTORIAL_TIMEOUT: 1200s - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip .[tutorial] black[jupyter] - - - name: Setup FFmpeg - uses: FedericoCarboni/setup-ffmpeg@v2 - - - name: Configure git - run: | - git config user.name "github-actions[bot]" - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - - - name: Run formatter - run: black tutorials/ - - - name: Export all tutorials to .py and .html - run: | - set -x - # Find all .ipynb files in the tutorials directory - for file in $(find tutorials -type f -name "*.ipynb"); do - filename=$(basename $file) - pyfilename="${filename%.ipynb}.py" - timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file) - htmlfilename="${filename%.ipynb}.html" - htmldir="docs/source"/$(dirname $file) - timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir - done - set +x - - - uses: benjlevesque/short-sha@v2.1 - id: short-sha - - - name: Remove unwanted files - run: | - rm -rf build/ tutorials/tutorial4/data/ - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5.0.2 - with: - labels: maintenance - title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }} - branch: export-tutorial-${{ steps.short-sha.outputs.sha }} - base: ${{ github.head_ref }} - commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }} - delete-branch: true + + # Create a PR + - uses: benjlevesque/short-sha@v2.1 + id: short-sha + + - name: Remove unwanted files + run: | + rm -rf build/ + rm -rf tutorials/tutorial12/SegTrackv2/ + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5.0.2 + with: + labels: maintenance + title: Export tutorial to .py in ${{ steps.short-sha.outputs.sha }} + branch: export-tutorial-${{ steps.short-sha.outputs.sha }} + commit-message: export tutorial to .py in ${{ steps.short-sha.outputs.sha }} + delete-branch: true + + - name: Add workflow result as comment on PR + uses: actions/github-script@v6 + if: always() + with: + script: | + const name = '${{ github.workflow }}'; + const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; + const success = '${{ job.status }}' === 'success'; + const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }) + + - name: Set latest commit status as ${{ job.status }} + uses: myrotvorets/set-commit-status-action@master + if: always() + with: + sha: ${{ steps.comment-branch.outputs.head_sha }} + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} \ No newline at end of file diff --git a/docs/source/tutorials/tutorial1/tutorial.html b/docs/source/tutorials/tutorial1/tutorial.html deleted file mode 100644 index 3d8bffc16..000000000 --- a/docs/source/tutorials/tutorial1/tutorial.html +++ /dev/null @@ -1,8131 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial10/tutorial.html b/docs/source/tutorials/tutorial10/tutorial.html deleted file mode 100644 index 9f8312553..000000000 --- a/docs/source/tutorials/tutorial10/tutorial.html +++ /dev/null @@ -1,8063 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial11/tutorial.html b/docs/source/tutorials/tutorial11/tutorial.html deleted file mode 100644 index 912f398bf..000000000 --- a/docs/source/tutorials/tutorial11/tutorial.html +++ /dev/null @@ -1,8652 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
-
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial12/tutorial.html b/docs/source/tutorials/tutorial12/tutorial.html deleted file mode 100644 index 03267fd85..000000000 --- a/docs/source/tutorials/tutorial12/tutorial.html +++ /dev/null @@ -1,7809 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
-
- - diff --git a/docs/source/tutorials/tutorial13/tutorial.html b/docs/source/tutorials/tutorial13/tutorial.html deleted file mode 100644 index 702f68bde..000000000 --- a/docs/source/tutorials/tutorial13/tutorial.html +++ /dev/null @@ -1,8150 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- - -
- - -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial14/tutorial.html b/docs/source/tutorials/tutorial14/tutorial.html deleted file mode 100644 index 760a93f3a..000000000 --- a/docs/source/tutorials/tutorial14/tutorial.html +++ /dev/null @@ -1,8003 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial15/tutorial.html b/docs/source/tutorials/tutorial15/tutorial.html deleted file mode 100644 index 3fadabe83..000000000 --- a/docs/source/tutorials/tutorial15/tutorial.html +++ /dev/null @@ -1,8379 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial17/tutorial.html b/docs/source/tutorials/tutorial17/tutorial.html deleted file mode 100644 index 51508853c..000000000 --- a/docs/source/tutorials/tutorial17/tutorial.html +++ /dev/null @@ -1,8499 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial18/tutorial.html b/docs/source/tutorials/tutorial18/tutorial.html deleted file mode 100644 index e44f7a51e..000000000 --- a/docs/source/tutorials/tutorial18/tutorial.html +++ /dev/null @@ -1,8004 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial19/tutorial.html b/docs/source/tutorials/tutorial19/tutorial.html deleted file mode 100644 index 6c6f7ec9f..000000000 --- a/docs/source/tutorials/tutorial19/tutorial.html +++ /dev/null @@ -1,8233 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - diff --git a/docs/source/tutorials/tutorial2/tutorial.html b/docs/source/tutorials/tutorial2/tutorial.html deleted file mode 100644 index 7e50103a7..000000000 --- a/docs/source/tutorials/tutorial2/tutorial.html +++ /dev/null @@ -1,8451 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
-
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial20/tutorial.html b/docs/source/tutorials/tutorial20/tutorial.html deleted file mode 100644 index a3646f516..000000000 --- a/docs/source/tutorials/tutorial20/tutorial.html +++ /dev/null @@ -1,8030 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial3/tutorial.html b/docs/source/tutorials/tutorial3/tutorial.html deleted file mode 100644 index 20e1c3cef..000000000 --- a/docs/source/tutorials/tutorial3/tutorial.html +++ /dev/null @@ -1,8231 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial4/tutorial.html b/docs/source/tutorials/tutorial4/tutorial.html deleted file mode 100644 index cd619d98e..000000000 --- a/docs/source/tutorials/tutorial4/tutorial.html +++ /dev/null @@ -1,8848 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
-
- -
- -
-
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial5/tutorial.html b/docs/source/tutorials/tutorial5/tutorial.html deleted file mode 100644 index bb6203dce..000000000 --- a/docs/source/tutorials/tutorial5/tutorial.html +++ /dev/null @@ -1,8046 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial6/tutorial.html b/docs/source/tutorials/tutorial6/tutorial.html deleted file mode 100644 index b102a3145..000000000 --- a/docs/source/tutorials/tutorial6/tutorial.html +++ /dev/null @@ -1,8195 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
-
- - diff --git a/docs/source/tutorials/tutorial7/tutorial.html b/docs/source/tutorials/tutorial7/tutorial.html deleted file mode 100644 index c99fab973..000000000 --- a/docs/source/tutorials/tutorial7/tutorial.html +++ /dev/null @@ -1,8061 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- - -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial8/tutorial.html b/docs/source/tutorials/tutorial8/tutorial.html deleted file mode 100644 index 70cb91e79..000000000 --- a/docs/source/tutorials/tutorial8/tutorial.html +++ /dev/null @@ -1,8153 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
-
- -
- -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- - -
-
- -
-
- - - diff --git a/docs/source/tutorials/tutorial9/tutorial.html b/docs/source/tutorials/tutorial9/tutorial.html deleted file mode 100644 index 22c61fe9b..000000000 --- a/docs/source/tutorials/tutorial9/tutorial.html +++ /dev/null @@ -1,7980 +0,0 @@ - - - - - -tutorial - - - - - - - - - - - - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
- - -
-
- -
- - -
-
- -
- - -
-
- -
-
- - -