From 1a6a938c92c1d5961525488beed52411f1068e28 Mon Sep 17 00:00:00 2001 From: Marco Schmoecker Date: Mon, 8 Jun 2026 18:12:25 -0700 Subject: [PATCH 1/3] Implement JSON output for external consumers Added functionality to write a JSON bundle for external consumers, including schema version and generation timestamp. --- scripts/gen_additional_platforms.py | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/gen_additional_platforms.py b/scripts/gen_additional_platforms.py index 8fffa1980674..9c0dc4cb4635 100644 --- a/scripts/gen_additional_platforms.py +++ b/scripts/gen_additional_platforms.py @@ -19,12 +19,15 @@ 5. Output the result to assets/quick-start-additional-platforms.js """ +import datetime import json +import os +import re from pathlib import Path from typing import Dict, Any, Set, List + import markdown from markdown.extensions.codehilite import CodeHiliteExtension -import re BASE_DIR = Path(__file__).parent.parent ADDITIONAL_PLATFORM_DIR = BASE_DIR / "_additional_platforms" @@ -32,6 +35,12 @@ INCLUDES_DIR = BASE_DIR / "_includes" ASSETS_DIR = BASE_DIR / "assets" +# External consumer JSON bundle +# Bump SCHEMA_VERSION on any breaking change +# to the `platforms` / `html` shape. +SCHEMA_VERSION = 1 +JSON_OUT_PATH = "additional-platforms.json" + # Schema definitions derived from additional_platforms.md REQUIRED_TOP_LEVEL_FIELDS: Set[str] = {"name", "support_channel", "stable"} ALLOWED_TOP_LEVEL_FIELDS: Set[str] = {"name", "support_channel", "stable", "preview"} @@ -231,6 +240,22 @@ def write_output(content: str) -> None: print(f"Generated: {output_path}") +def write_platforms_json(platforms: dict, html: dict, out_path: str) -> None: + """ + Write JSON bundle for external consumers. + """ + payload = { + "schema_version": SCHEMA_VERSION, + "generated_at": datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds"), + "generator_commit": os.environ.get("GITHUB_SHA", "")[:7], + "platforms": platforms, + "html": html, + } + with open(out_path, "w", encoding="utf-8") as f: + json.dump(payload, f, indent=2, ensure_ascii=False, sort_keys=False) + print(f"Wrote {out_path}") + + def main(): """Main entry point.""" @@ -254,6 +279,9 @@ def main(): # Write to assets directory write_output(js_content) + # Also write the JSON file for the external consumer + write_platforms_json(platform_data, markdown_content, str(BASE_DIR / JSON_OUT_PATH)) + if __name__ == "__main__": main() From 34913cf68128cd50c7db46081421d24b5fb605b1 Mon Sep 17 00:00:00 2001 From: Marco Schmoecker Date: Mon, 8 Jun 2026 18:37:52 -0700 Subject: [PATCH 2/3] Update workflow to commit additional-platforms JS & JSON --- .../workflows/update-quick-start-module.yml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-quick-start-module.yml b/.github/workflows/update-quick-start-module.yml index 7c619b802bc8..42c936ab0096 100644 --- a/.github/workflows/update-quick-start-module.yml +++ b/.github/workflows/update-quick-start-module.yml @@ -134,8 +134,35 @@ jobs: with: python-version: 3.9 architecture: x64 - - name: Generate quick-start-additional-platforms.js + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install markdown pygments + - name: Generate additional-platforms assets shell: bash run: | set -ex python3 ./scripts/gen_additional_platforms.py + - name: Create Issue if failed + uses: dacbd/create-issue-action@main + if: ${{ failure() }} # only run when this job is failed. + with: + title: Updating additional platforms failed + token: ${{secrets.PYTORCHBOT_TOKEN}} + assignees: ${{github.actor}} + labels: bug + body: Updating additional platforms failed, please fix gen_additional_platforms.py + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.PYTORCHBOT_TOKEN }} + commit-message: Regenerate additional-platforms assets + title: '[Additional Platforms] Regenerate quick-start-additional-platforms.js and additional-platforms.json' + body: > + This PR is auto-generated. It regenerates the third-party vendor + accelerator picker assets after a change to _additional_platforms/*.json + or _get_started/additional_platforms/*.md. + labels: automated pr + add-paths: | + assets/quick-start-additional-platforms.js + assets/additional-platforms.json From 3226585d7d26907a2f519480accd00ecc2aa1bce Mon Sep 17 00:00:00 2001 From: Marco Schmoecker Date: Mon, 15 Jun 2026 09:10:22 -0700 Subject: [PATCH 3/3] Update workflow actions and remove issue creation step Pin action versions to commit SHA in the workflow and removed the issue creation step. --- .github/workflows/update-quick-start-module.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/update-quick-start-module.yml b/.github/workflows/update-quick-start-module.yml index 42c936ab0096..048891425565 100644 --- a/.github/workflows/update-quick-start-module.yml +++ b/.github/workflows/update-quick-start-module.yml @@ -128,9 +128,9 @@ jobs: environment: pytorchbot-env steps: - name: Checkout pytorch.github.io - uses: actions/checkout@v2 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 with: python-version: 3.9 architecture: x64 @@ -143,17 +143,8 @@ jobs: run: | set -ex python3 ./scripts/gen_additional_platforms.py - - name: Create Issue if failed - uses: dacbd/create-issue-action@main - if: ${{ failure() }} # only run when this job is failed. - with: - title: Updating additional platforms failed - token: ${{secrets.PYTORCHBOT_TOKEN}} - assignees: ${{github.actor}} - labels: bug - body: Updating additional platforms failed, please fix gen_additional_platforms.py - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7 with: token: ${{ secrets.PYTORCHBOT_TOKEN }} commit-message: Regenerate additional-platforms assets