From 1346b9a7f944d97ece2adb0eea98bc24877f2a56 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 13 May 2022 09:15:56 +0200 Subject: [PATCH] fix incorrect patched distributions template (#75) * fix incorrect patched distributions template * remove multiline once again * remove comments --- .../incorrect_pytorch_dists_issue_template.md | 2 +- .../check-available-pytorch-dists.yml | 29 ++++++++++++++++--- requirements-dev.txt | 1 + scripts/check_available_pytorch_dists.py | 3 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/incorrect_pytorch_dists_issue_template.md b/.github/incorrect_pytorch_dists_issue_template.md index 9abe9ad..a701501 100644 --- a/.github/incorrect_pytorch_dists_issue_template.md +++ b/.github/incorrect_pytorch_dists_issue_template.md @@ -8,7 +8,7 @@ the wheels hosted by PyTorch. Please replace it with ```py PYTORCH_DISTRIBUTIONS = { -{%- for dist in env.PYTORCH_DISTRIBUTIONS %} +{%- for dist in env.PYTORCH_DISTRIBUTIONS.split(",") %} "{{ dist }}", {%- endfor %} } diff --git a/.github/workflows/check-available-pytorch-dists.yml b/.github/workflows/check-available-pytorch-dists.yml index 49e435c..5b7a1bd 100644 --- a/.github/workflows/check-available-pytorch-dists.yml +++ b/.github/workflows/check-available-pytorch-dists.yml @@ -26,16 +26,37 @@ jobs: - name: Check available PyTorch distributions id: pytorch-dists run: | - PYTORCH_DISTS=$(python scripts/check_available_pytorch_dists.py) + PYTORCH_DISTS=`python scripts/check_available_pytorch_dists.py` echo "::set-output name=pytorch-dists::${PYTORCH_DISTS}" if [[ -n "${PYTORCH_DISTS}" ]]; then { echo "${PYTORCH_DISTS}"; exit 1; }; fi + - name: Check template + if: failure() && github.event_name != 'schedule' + shell: python + env: + PYTORCH_DISTRIBUTIONS: ${{ steps.pytorch-dists.outputs.pytorch-dists }} + run: | + import os + import pathlib + + import jinja2 + + path = pathlib.Path.cwd() / ".github" + loader = jinja2.FileSystemLoader(searchpath=path) + env = jinja2.Environment(loader=loader) + template = env.get_template("incorrect_pytorch_dists_issue_template.md") + + print( + template.render( + env={"PYTORCH_DISTRIBUTIONS": os.environ["PYTORCH_DISTRIBUTIONS"]}, + ) + ) + - uses: JasonEtco/create-an-issue@v2.6.0 if: failure() && github.event_name == 'schedule' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PYTORCH_DISTRIBUTIONS: - ${{ toJSON(steps.pytorch-dists.outputs.pytorch-dists) }} + PYTORCH_DISTRIBUTIONS: ${{ steps.pytorch-dists.outputs.pytorch-dists }} with: filename: .github/incorrect_pytorch_dists_issue_template.md - update_existing: true + update_existing: false diff --git a/requirements-dev.txt b/requirements-dev.txt index ba4812c..52f6b92 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,3 +13,4 @@ check-wheel-contents # misc requests beautifulsoup4 +jinja2 diff --git a/scripts/check_available_pytorch_dists.py b/scripts/check_available_pytorch_dists.py index d3a5a2f..444ffc7 100755 --- a/scripts/check_available_pytorch_dists.py +++ b/scripts/check_available_pytorch_dists.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import itertools -import json import requests from bs4 import BeautifulSoup @@ -48,7 +47,7 @@ def main(): extra = PATCHED_PYTORCH_DISTS - available if missing or extra: - print(json.dumps(sorted(available))) + print(",".join(sorted(available))) if __name__ == "__main__":