From f508c80c23a08e429c24f2bb61565f9574816ce0 Mon Sep 17 00:00:00 2001 From: Ean Garvey <87458719+monorimet@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:03:33 -0500 Subject: [PATCH] Add workflow for GH pages releases and release scraping script. (#394) * Add workflow for GH pages releases and release scraping script. * Update test_models.py and change tokens for gh pages. --- .github/workflows/gh-pages-releases.yml | 37 +++++++++++++++++++++++++ .github/workflows/nightly.yml | 13 +++++---- README.md | 2 +- build_tools/scrape_releases.py | 37 +++++++++++++++++++++++++ tank/test_models.py | 11 ++++++-- tank/tf/tf_model_black_list.csv | 1 + tank/tf/tf_model_list.csv | 1 - 7 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/gh-pages-releases.yml create mode 100644 build_tools/scrape_releases.py create mode 100644 tank/tf/tf_model_black_list.csv diff --git a/.github/workflows/gh-pages-releases.yml b/.github/workflows/gh-pages-releases.yml new file mode 100644 index 00000000..eef086e4 --- /dev/null +++ b/.github/workflows/gh-pages-releases.yml @@ -0,0 +1,37 @@ +# See: https://github.com/llvm/torch-mlir/issues/1374 +name: Publish releases page + +on: + workflow_dispatch: + +jobs: + scrape_and_publish_releases: + name: "Scrape and publish releases" + runs-on: ubuntu-latest + + # Don't run this in everyone's forks. + if: github.repository == 'nod-ai/SHARK' + + steps: + - name: Checking out repository + uses: actions/checkout@v2 + with: + token: ${{ secrets.NODAI_INVOCATION_TOKEN }} + - name: Run scrape releases script + run: python ./build_tools/scrape_releases.py nod-ai SHARK > /tmp/index.html + shell: bash + - run: git fetch --all + - run: git switch github-pages + - run: git config --global user.email "none@none.com" + - run: git config --global user.name "nod-team" + - run: mv /tmp/index.html package-index/index.html + - run: git add package-index/index.html + + # Only try to make a commit if the file has changed. + - run: git diff --cached --exit-code || git commit -m "Update releases." + + - name: GitHub Push + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.NODAI_INVOCATION_TOKEN }} + branch: github-pages diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7d4c3836..0f4e7dec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -39,6 +39,10 @@ jobs: tag_name="${package_version}" echo "package_version=${package_version}" >> $GITHUB_ENV echo "tag_name=${tag_name}" >> $GITHUB_ENV + - name: Set Environment Variables + run: | + echo "SHORT_SHA=`git rev-parse --short=4 HEAD`" >> $GITHUB_ENV + echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Create Release id: create_release uses: actions/create-release@v1 @@ -81,7 +85,7 @@ jobs: pip install ./wheelhouse/nodai* # Validate the Models /bin/bash "$GITHUB_WORKSPACE/build_tools/populate_sharktank_ci.sh" - pytest tank/test_models.py | + pytest --ci --ci_sha=${SHORT_SHA} --local_tank_cache="./gen_shark_tank/" tank/test_models.py | tail -n 1 | tee -a pytest_results.txt if !(grep -Fxq " failed" pytest_results.txt) @@ -104,13 +108,10 @@ jobs: # Install the built wheel pip install ./wheelhouse/nodai* # Validate the Models - pytest tank/test_models.py | + pytest --ci --ci_sha=${SHORT_SHA} --local_tank_cache="./gen_shark_tank/" tank/test_models.py | tail -n 1 | tee -a pytest_results.txt - publish: - runs-on: a100 - needs: build - steps: + - name: Upload Release Assets if: ${{ matrix.backend == 'SHARK' }} id: upload-release-assets diff --git a/README.md b/README.md index dd96a021..8a2be625 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ python -m pip install --upgrade pip This step pip installs SHARK and related packages on Linux Python 3.7, 3.8, 3.9, 3.10 and macOS Python 3.10 ```shell -pip install nodai-shark -f https://github.com/nod-ai/SHARK/releases -f https://github.com/llvm/torch-mlir/releases -f https://github.com/nod-ai/shark-runtime/releases --extra-index-url https://download.pytorch.org/whl/nightly/cpu +pip install nodai-shark -f https://nod-ai.github.io/SHARK/package-index/ -f https://llvm.github.io/torch-mlir/package-index/ -f https://github.com/nod-ai/shark-runtime/releases --extra-index-url https://download.pytorch.org/whl/nightly/cpu ``` If you are on an Intel macOS machine you need this [workaround](https://github.com/nod-ai/SHARK/issues/102) for an upstream issue. diff --git a/build_tools/scrape_releases.py b/build_tools/scrape_releases.py new file mode 100644 index 00000000..88f19d92 --- /dev/null +++ b/build_tools/scrape_releases.py @@ -0,0 +1,37 @@ +"""Scrapes the github releases API to generate a static pip-install-able releases page. + +See https://github.com/llvm/torch-mlir/issues/1374 +""" +import argparse +import json + +import requests + +# Parse arguments +parser = argparse.ArgumentParser() +parser.add_argument("owner", type=str) +parser.add_argument("repo", type=str) +args = parser.parse_args() + +# Get releases +response = requests.get( + f"https://api.github.com/repos/{args.owner}/{args.repo}/releases" +) +body = json.loads(response.content) + +# Parse releases +releases = [] +for row in body: + for asset in row["assets"]: + releases.append((asset["name"], asset["browser_download_url"])) + +# Output HTML +html = """ + +
+""" +for name, url in releases: + html += f" {name}