From 323f25f27029897f1b9aa94947cca822759138ba Mon Sep 17 00:00:00 2001 From: can-gaa-hou Date: Sat, 9 May 2026 17:17:35 +0800 Subject: [PATCH 1/6] Add ecosystem platform page for third-party vendor --- .../workflows/update-quick-start-module.yml | 43 +++ .../get-started-ecosystem-platform.md | 22 ++ _get_started/get-started-locally.md | 4 + _includes/quick-start-ecosystem-platform.js | 339 ++++++++++++++++++ _includes/quick_start_ecosystem_platform.html | 112 ++++++ scripts/gen_ecosystem_platform.py | 97 +++++ 6 files changed, 617 insertions(+) create mode 100644 _get_started/get-started-ecosystem-platform.md create mode 100644 _includes/quick-start-ecosystem-platform.js create mode 100644 _includes/quick_start_ecosystem_platform.html create mode 100644 scripts/gen_ecosystem_platform.py diff --git a/.github/workflows/update-quick-start-module.yml b/.github/workflows/update-quick-start-module.yml index bf6956011c9f..630ff27d0790 100644 --- a/.github/workflows/update-quick-start-module.yml +++ b/.github/workflows/update-quick-start-module.yml @@ -7,16 +7,22 @@ on: paths: - .github/workflows/update-quick-start-module.yml - scripts/gen_quick_start_module.py + - scripts/gen_ecosystem_platform.py - _includes/quick-start-module.js - _includes/quick_start_local.html + - _includes/quick-start-ecosystem-platform.js + - _ecosystem_platform/*.json push: branches: site paths: - .github/workflows/update-quick-start-module.yml - scripts/gen_quick_start_module.py + - scripts/gen_ecosystem_platform.py - _includes/quick-start-module.js - _includes/quick_start_local.html + - _includes/quick-start-ecosystem-platform.js + - _ecosystem_platform/*.json workflow_dispatch: jobs: @@ -116,3 +122,40 @@ jobs: body: > This PR is auto-generated. It updates Getting Started page labels: automated pr + + update-ecosystem-platform: + needs: [linux-nightly-matrix, windows-nightly-matrix, macos-arm64-nightly-matrix, + linux-release-matrix, windows-release-matrix, macos-arm64-release-matrix] + runs-on: "ubuntu-latest" + environment: pytorchbot-env + steps: + - name: Checkout pytorch.github.io + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + architecture: x64 + - name: Generate quick-start-ecosystem-platform.js + shell: bash + run: | + set -ex + python3 ./scripts/gen_ecosystem_platform.py + - name: Create Issue if failed + uses: dacbd/create-issue-action@main + if: ${{ failure() }} + with: + title: Updating ecosystem platform quick start module failed + token: ${{secrets.PYTORCHBOT_TOKEN}} + assignees: ${{github.actor}} + labels: bug + body: Updating ecosystem platform quick start module failed, please fix the update script or check JSON files + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.PYTORCHBOT_TOKEN }} + commit-message: Update quick-start-ecosystem-platform.js + title: '[Ecosystem Platform] Update quick-start-ecosystem-platform.js' + body: > + This PR is auto-generated. It updates the Ecosystem Platform Getting Started page + labels: automated pr diff --git a/_get_started/get-started-ecosystem-platform.md b/_get_started/get-started-ecosystem-platform.md new file mode 100644 index 000000000000..76734d6b135a --- /dev/null +++ b/_get_started/get-started-ecosystem-platform.md @@ -0,0 +1,22 @@ +--- +layout: get_started +title: Ecosystem Platform +permalink: /get-started/ecosystem-platform/ +background-class: get-started-background +body-class: get-started +order: 1 +published: true +get-started-ecosystem: true +--- + +
+
+
+ {% include quick_start_ecosystem_platform.html %} +
+
+
+ + + + diff --git a/_get_started/get-started-locally.md b/_get_started/get-started-locally.md index 6a95566a3946..a493714a7103 100644 --- a/_get_started/get-started-locally.md +++ b/_get_started/get-started-locally.md @@ -20,6 +20,10 @@ redirect_from: "/get-started/" +
+

Could not find the right binary for your hardware? See the PyTorch Ecosystem Platform page.

+
+ --- {% capture mac %} diff --git a/_includes/quick-start-ecosystem-platform.js b/_includes/quick-start-ecosystem-platform.js new file mode 100644 index 000000000000..4588689b13e3 --- /dev/null +++ b/_includes/quick-start-ecosystem-platform.js @@ -0,0 +1,339 @@ +// ===================================================== +// Ecosystem Platform Quick Start Module +// ===================================================== + +// Platform data loaded from JSON files (generated by gen_ecosystem_platform.py) +var ecosystemPlatformData = {{ platformData }}; + +// Get platform IDs from loaded data +var ecosystemPlatformIds = Object.keys(ecosystemPlatformData); + +// Ecosystem platform selections +var ecosystemOpts = { + build: 'stable', + os: 'linux', + pm: 'pip', + language: 'python', + platform: null, + version: null +}; + +// Initialize ecosystem platform when document is ready +$(function() { + initEcosystemPlatform(); + generateComputePlatformOptions(); + disableUnsupportedEcosystemPlatforms(ecosystemOpts.os); +}); + +// Dynamically generate compute platform options from loaded JSON data +function generateComputePlatformOptions() { + var container = $('.compute-platform'); + var count = ecosystemPlatformIds.length; + var colClass = count === 1 ? 'col-md-12' : + count === 2 ? 'col-md-6' : + count === 3 ? 'col-md-4' : 'col-md-3'; + + ecosystemPlatformIds.forEach(function(platformId) { + var platform = ecosystemPlatformData[platformId]; + var displayName = platform ? (platform.name + ' (' + platform.vendor + ')') : platformId.toUpperCase(); + var optionHtml = '
' + + '
' + displayName + '
' + + '
'; + container.append(optionHtml); + }); + + // Bind click events for newly created options + $('.compute-platform-option').on('click', function() { + var platformId = this.id; + + // Check if this platform is supported on current OS + var supportedOS = getSupportedOS(platformId); + if (!supportedOS.includes(ecosystemOpts.os)) { + // Platform not supported, don't select it + return; + } + + selectEcosystemPlatform(platformId); + }); +} + +// Get supported OS list from platform data structure +function getSupportedOS(platformId) { + var platform = ecosystemPlatformData[platformId]; + if (!platform) return []; + + // Extract OS from both stable and preview + var osSet = new Set(); + ['stable', 'preview'].forEach(function(build) { + if (platform[build]) { + Object.keys(platform[build]).forEach(function(os) { + osSet.add(os); + }); + } + }); + return Array.from(osSet); +} + +// Get supported packages for platform on current OS and build +function getSupportedPackages(platformId, os, build) { + var platform = ecosystemPlatformData[platformId]; + if (!platform || !platform[build] || !platform[build][os]) return []; + return Object.keys(platform[build][os]); +} + +// Get supported languages for platform on current OS, build, and package +function getSupportedLanguages(platformId, os, build, pm) { + var platform = ecosystemPlatformData[platformId]; + if (!platform || !platform[build] || !platform[build][os] || !platform[build][os][pm]) return []; + return Object.keys(platform[build][os][pm]); +} + +// Get available versions for platform on current selections +function getAvailableVersions(platformId, os, build, pm, language) { + var platform = ecosystemPlatformData[platformId]; + if (!platform || !platform[build] || !platform[build][os] || !platform[build][os][pm] || !platform[build][os][pm][language]) return []; + return Object.keys(platform[build][os][pm][language]); +} + +// Disable compute platforms not supported on selected OS +function disableUnsupportedEcosystemPlatforms(os) { + $('.compute-platform-option').each(function() { + var platformId = this.id; + var supportedOS = getSupportedOS(platformId); + var isSupported = supportedOS.includes(os); + + // Apply or remove strikethrough style + this.style.textDecoration = isSupported ? "" : "line-through"; + + // Add disabled class for visual feedback + if (isSupported) { + $(this).removeClass('disabled-platform'); + } else { + $(this).addClass('disabled-platform'); + } + }); + + // If currently selected platform is not supported on new OS, deselect it + if (ecosystemOpts.platform) { + var supportedOS = getSupportedOS(ecosystemOpts.platform); + if (!supportedOS.includes(os)) { + ecosystemOpts.platform = null; + ecosystemOpts.version = null; + $('.compute-platform-option').removeClass('selected'); + $('#version-row').hide(); + $('.version-heading').hide(); + $('#command').html('Select a compute platform to see the installation command.'); + } + } +} + +// Initialize all click events +function initEcosystemPlatform() { + // PyTorch Build + $('.pytorch-build > .option').on('click', function() { + $('.pytorch-build > .option').removeClass('selected'); + $(this).addClass('selected'); + ecosystemOpts.build = this.id; + updateEcosystemVersions(); + updateEcosystemCommand(); + }); + + // OS - with platform support check + $('.os-ecosystem > .option').on('click', function() { + $('.os-ecosystem > .option').removeClass('selected'); + $(this).addClass('selected'); + ecosystemOpts.os = this.id; + + // Update platform strikethrough based on OS + disableUnsupportedEcosystemPlatforms(this.id); + + updateEcosystemVersions(); + updateEcosystemCommand(); + }); + + // Package - with language binding + $('.package-ecosystem > .option').on('click', function() { + var packageId = this.id; + + $('.package-ecosystem > .option').removeClass('selected'); + $(this).addClass('selected'); + ecosystemOpts.pm = packageId; + + // Package-Language binding: pip/source -> python, libtorch -> cpp + if (packageId === 'libtorch') { + $('.language-ecosystem > .option').removeClass('selected'); + $('#cpp').addClass('selected'); + ecosystemOpts.language = 'cpp'; + } else { + // pip or source -> python + $('.language-ecosystem > .option').removeClass('selected'); + $('#python').addClass('selected'); + ecosystemOpts.language = 'python'; + } + + updateEcosystemVersions(); + updateEcosystemCommand(); + }); + + // Language - with package binding + $('.language-ecosystem > .option').on('click', function() { + var languageId = this.id; + + $('.language-ecosystem > .option').removeClass('selected'); + $(this).addClass('selected'); + ecosystemOpts.language = languageId; + + // Package-Language binding: python -> pip/source, cpp -> libtorch + if (languageId === 'cpp') { + $('.package-ecosystem > .option').removeClass('selected'); + $('#libtorch').addClass('selected'); + ecosystemOpts.pm = 'libtorch'; + } else { + // python -> pip + $('.package-ecosystem > .option').removeClass('selected'); + $('#pip').addClass('selected'); + ecosystemOpts.pm = 'pip'; + } + + updateEcosystemVersions(); + updateEcosystemCommand(); + }); +} + +// Select ecosystem platform and show versions +function selectEcosystemPlatform(platformId) { + ecosystemOpts.platform = platformId; + ecosystemOpts.version = null; + + // Update UI + $('.compute-platform-option').removeClass('selected'); + $('#' + platformId).addClass('selected'); + + // Show version row + $('#version-row').show(); + $('.version-heading').show(); + + // Load versions + updateEcosystemVersions(); + updateEcosystemCommand(); +} + +// Update version options based on current selections +function updateEcosystemVersions() { + if (!ecosystemOpts.platform) return; + + var platform = ecosystemPlatformData[ecosystemOpts.platform]; + if (!platform) return; + + var versions = getAvailableVersions( + ecosystemOpts.platform, + ecosystemOpts.os, + ecosystemOpts.build, + ecosystemOpts.pm, + ecosystemOpts.language + ); + + var row = $('#version-row'); + + // Remove old version options (keep mobile-heading) + row.find('.option.block').remove(); + + if (versions.length === 0) { + $('#command').html('No versions available for this configuration'); + return; + } + + versions.forEach(function(version) { + var colClass = versions.length === 1 ? 'col-md-12' : + versions.length === 2 ? 'col-md-6' : 'col-md-4'; + var optionHtml = '
' + + '
' + version + '
' + + '
'; + row.append(optionHtml); + }); + + // Bind click events for version options using data attribute + row.find('.option.block').on('click', function() { + var versionId = $(this).attr('data-version'); + selectEcosystemVersion(versionId, this); + }); + + // Auto-select first version if current version not in list + if (versions.length > 0) { + if (!ecosystemOpts.version || !versions.includes(ecosystemOpts.version)) { + var firstOption = row.find('.option.block').first(); + selectEcosystemVersion(versions[0], firstOption); + } + } +} + +// Select ecosystem version +function selectEcosystemVersion(versionId, element) { + ecosystemOpts.version = versionId; + + $('#version-row .option.block').removeClass('selected'); + if (element) { + $(element).addClass('selected'); + } + + updateEcosystemCommand(); +} + +// Update ecosystem command based on selections +function updateEcosystemCommand() { + if (!ecosystemOpts.platform) { + $('#command').html('Select a compute platform to see the installation command.'); + return; + } + + var platform = ecosystemPlatformData[ecosystemOpts.platform]; + if (!platform) { + $('#command').html('Loading platform data...'); + return; + } + + // Check if OS is supported + var supportedOS = getSupportedOS(ecosystemOpts.platform); + if (!supportedOS.includes(ecosystemOpts.os)) { + $('#command').html('' + platform.name + ' is not supported on ' + ecosystemOpts.os + ''); + return; + } + + // Check if package is supported + var supportedPackages = getSupportedPackages(ecosystemOpts.platform, ecosystemOpts.os, ecosystemOpts.build); + if (!supportedPackages.includes(ecosystemOpts.pm)) { + $('#command').html('' + platform.name + ' does not support ' + ecosystemOpts.pm + ' package on ' + ecosystemOpts.os + ''); + return; + } + + // Check if language is supported + var supportedLanguages = getSupportedLanguages(ecosystemOpts.platform, ecosystemOpts.os, ecosystemOpts.build, ecosystemOpts.pm); + if (!supportedLanguages.includes(ecosystemOpts.language)) { + $('#command').html('' + platform.name + ' does not support ' + ecosystemOpts.language + ' with ' + ecosystemOpts.pm + ''); + return; + } + + // Get available versions + var versions = getAvailableVersions(ecosystemOpts.platform, ecosystemOpts.os, ecosystemOpts.build, ecosystemOpts.pm, ecosystemOpts.language); + if (versions.length === 0) { + $('#command').html('No versions available for this configuration'); + return; + } + + // Auto-select first version if not selected + if (!ecosystemOpts.version || !versions.includes(ecosystemOpts.version)) { + ecosystemOpts.version = versions[0]; + } + + // Get command from new format: platform[build][os][pm][language][version] + try { + var cmd = platform[ecosystemOpts.build][ecosystemOpts.os][ecosystemOpts.pm][ecosystemOpts.language][ecosystemOpts.version]; + if (cmd) { + $('#command').html('
' + cmd + '
'); + } else { + $('#command').html('Configuration not available for this combination'); + } + } catch (e) { + $('#command').html('Configuration not available for this combination'); + } +} diff --git a/_includes/quick_start_ecosystem_platform.html b/_includes/quick_start_ecosystem_platform.html new file mode 100644 index 000000000000..7e76c913cb1d --- /dev/null +++ b/_includes/quick_start_ecosystem_platform.html @@ -0,0 +1,112 @@ +

Select your compute platform and configuration to get the installation command. These platforms provide alternative hardware acceleration options beyond NVIDIA CUDA.

+ +
+
+
+
PyTorch Build
+
+
+
Your OS
+
+
+
Package
+
+
+
Language
+
+
+
Compute Platform
+
+ +
+
Run this Command:
+
+
+ +
+ +
+
+
PyTorch Build
+
+
+
Stable (2.11.0)
+
+
+
Preview (Nightly)
+
+
+ + +
+
+
Your OS
+
+
+
Linux
+
+
+
Windows
+
+
+ + +
+
+
Package
+
+
+
Pip
+
+
+
LibTorch
+
+
+
Source
+
+
+ + +
+
+
Language
+
+
+
Python
+
+
+
C++/Java
+
+
+ + +
+
+
Compute Platform
+
+ +
+ + + + + +
+
+
Run this Command:
+
+
+
Select a compute platform to see the installation command.
+
+
+
+
+ + diff --git a/scripts/gen_ecosystem_platform.py b/scripts/gen_ecosystem_platform.py new file mode 100644 index 000000000000..d81056d90081 --- /dev/null +++ b/scripts/gen_ecosystem_platform.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +""" +Generates ecosystem platform quick start module for +https://pytorch.org/get-started/ecosystem-platform/ page. + +This script reads all JSON files from _ecosystem_platform/ directory, +combines them, and generates the quick-start-ecosystem-platform.js file. + +Usage: + python3 scripts/gen_ecosystem_platform.py + +The script will: +1. Read all JSON files from _ecosystem_platform/ directory +2. Combine platform data into a single object (keyed by filename) +3. Replace template placeholders in _includes/quick-start-ecosystem-platform.js +4. Output the result to assets/quick-start-ecosystem-platform.js +""" + +import json +from pathlib import Path +from typing import Dict, Any + +BASE_DIR = Path(__file__).parent.parent +ECOSYSTEM_PLATFORM_DIR = BASE_DIR / "_ecosystem_platform" +INCLUDES_DIR = BASE_DIR / "_includes" +ASSETS_DIR = BASE_DIR / "assets" + + +def read_platform_json_files() -> Dict[str, Any]: + """Read all JSON files from _ecosystem_platform directory.""" + platform_data = {} + + if not ECOSYSTEM_PLATFORM_DIR.exists(): + print(f"Warning: {ECOSYSTEM_PLATFORM_DIR} does not exist") + return platform_data + + for json_file in ECOSYSTEM_PLATFORM_DIR.glob("*.json"): + try: + content = json_file.read_text() + data = json.loads(content) + # Use filename (without .json) as platform_id + platform_id = json_file.stem + platform_data[platform_id] = data + print(f"Loaded platform: {platform_id} from {json_file.name}") + except json.JSONDecodeError as e: + print(f"Error parsing {json_file.name}: {e}") + + return platform_data + + +def read_template() -> str: + """Read the JS template file.""" + template_path = INCLUDES_DIR / "quick-start-ecosystem-platform.js" + if not template_path.exists(): + raise FileNotFoundError(f"Template file not found: {template_path}") + return template_path.read_text() + + +def generate_js_output(platform_data: Dict[str, Any]) -> str: + """Generate the final JS file by replacing template placeholders.""" + template = read_template() + + # Replace placeholders + template = template.replace("{{ platformData }}", json.dumps(platform_data, indent=2)) + + return template + + +def write_output(content: str) -> None: + """Write the generated JS to assets directory.""" + output_path = ASSETS_DIR / "quick-start-ecosystem-platform.js" + output_path.write_text(content) + print(f"Generated: {output_path}") + + +def main(): + """Main entry point.""" + print("Generating ecosystem platform quick start module...") + + # Read all platform JSON files + platform_data = read_platform_json_files() + + if not platform_data: + print("No platform data found. Creating empty output.") + platform_data = {} + + # Generate JS output + js_content = generate_js_output(platform_data) + + # Write to assets directory + write_output(js_content) + + print("Done!") + + +if __name__ == "__main__": + main() From 72924bfec23470e22b92b3a693bc9d252076403d Mon Sep 17 00:00:00 2001 From: can-gaa-hou Date: Tue, 12 May 2026 20:33:21 +0800 Subject: [PATCH 2/6] Add additional platform quick start module and update related workflows --- .../workflows/update-quick-start-module.yml | 28 +- ....md => get-started-additional-platform.md} | 10 +- _get_started/get-started-locally.md | 2 +- ....js => quick-start-additional-platform.js} | 274 ++++++++++-------- ...l => quick_start_additional_platform.html} | 25 +- ...platform.py => gen_additional_platform.py} | 32 +- 6 files changed, 196 insertions(+), 175 deletions(-) rename _get_started/{get-started-ecosystem-platform.md => get-started-additional-platform.md} (59%) rename _includes/{quick-start-ecosystem-platform.js => quick-start-additional-platform.js} (61%) rename _includes/{quick_start_ecosystem_platform.html => quick_start_additional_platform.html} (82%) rename scripts/{gen_ecosystem_platform.py => gen_additional_platform.py} (66%) diff --git a/.github/workflows/update-quick-start-module.yml b/.github/workflows/update-quick-start-module.yml index 630ff27d0790..63ff008c38e1 100644 --- a/.github/workflows/update-quick-start-module.yml +++ b/.github/workflows/update-quick-start-module.yml @@ -7,22 +7,22 @@ on: paths: - .github/workflows/update-quick-start-module.yml - scripts/gen_quick_start_module.py - - scripts/gen_ecosystem_platform.py + - scripts/gen_additional_platform.py - _includes/quick-start-module.js - _includes/quick_start_local.html - - _includes/quick-start-ecosystem-platform.js - - _ecosystem_platform/*.json + - _includes/quick-start-additional-platform.js + - _additional_platform/*.json push: branches: site paths: - .github/workflows/update-quick-start-module.yml - scripts/gen_quick_start_module.py - - scripts/gen_ecosystem_platform.py + - scripts/gen_additional_platform.py - _includes/quick-start-module.js - _includes/quick_start_local.html - - _includes/quick-start-ecosystem-platform.js - - _ecosystem_platform/*.json + - _includes/quick-start-additional-platform.js + - _additional_platform/*.json workflow_dispatch: jobs: @@ -123,7 +123,7 @@ jobs: This PR is auto-generated. It updates Getting Started page labels: automated pr - update-ecosystem-platform: + update-additional-platform: needs: [linux-nightly-matrix, windows-nightly-matrix, macos-arm64-nightly-matrix, linux-release-matrix, windows-release-matrix, macos-arm64-release-matrix] runs-on: "ubuntu-latest" @@ -136,26 +136,26 @@ jobs: with: python-version: 3.9 architecture: x64 - - name: Generate quick-start-ecosystem-platform.js + - name: Generate quick-start-additional-platform.js shell: bash run: | set -ex - python3 ./scripts/gen_ecosystem_platform.py + python3 ./scripts/gen_additional_platform.py - name: Create Issue if failed uses: dacbd/create-issue-action@main if: ${{ failure() }} with: - title: Updating ecosystem platform quick start module failed + title: Updating additional platform quick start module failed token: ${{secrets.PYTORCHBOT_TOKEN}} assignees: ${{github.actor}} labels: bug - body: Updating ecosystem platform quick start module failed, please fix the update script or check JSON files + body: Updating additional platform quick start module failed, please fix the update script or check JSON files - name: Create Pull Request uses: peter-evans/create-pull-request@v3 with: token: ${{ secrets.PYTORCHBOT_TOKEN }} - commit-message: Update quick-start-ecosystem-platform.js - title: '[Ecosystem Platform] Update quick-start-ecosystem-platform.js' + commit-message: Update quick-start-additional-platform.js + title: '[Additional Platform] Update quick-start-additional-platform.js' body: > - This PR is auto-generated. It updates the Ecosystem Platform Getting Started page + This PR is auto-generated. It updates the Additional Platform Getting Started page labels: automated pr diff --git a/_get_started/get-started-ecosystem-platform.md b/_get_started/get-started-additional-platform.md similarity index 59% rename from _get_started/get-started-ecosystem-platform.md rename to _get_started/get-started-additional-platform.md index 76734d6b135a..4b1b7f429f00 100644 --- a/_get_started/get-started-ecosystem-platform.md +++ b/_get_started/get-started-additional-platform.md @@ -1,22 +1,22 @@ --- layout: get_started -title: Ecosystem Platform -permalink: /get-started/ecosystem-platform/ +title: Additional Platform +permalink: /get-started/additional-platform/ background-class: get-started-background body-class: get-started order: 1 published: true -get-started-ecosystem: true +get-started-additional: true ---
- {% include quick_start_ecosystem_platform.html %} + {% include quick_start_additional_platform.html %}
- + diff --git a/_get_started/get-started-locally.md b/_get_started/get-started-locally.md index a493714a7103..4a9ec08f0485 100644 --- a/_get_started/get-started-locally.md +++ b/_get_started/get-started-locally.md @@ -21,7 +21,7 @@ redirect_from: "/get-started/"
-

Could not find the right binary for your hardware? See the PyTorch Ecosystem Platform page.

+

Could not find the right binary for your hardware? See the PyTorch Additional Platform page.

--- diff --git a/_includes/quick-start-ecosystem-platform.js b/_includes/quick-start-additional-platform.js similarity index 61% rename from _includes/quick-start-ecosystem-platform.js rename to _includes/quick-start-additional-platform.js index 4588689b13e3..8a5f8fb489c8 100644 --- a/_includes/quick-start-ecosystem-platform.js +++ b/_includes/quick-start-additional-platform.js @@ -1,8 +1,8 @@ // ===================================================== -// Ecosystem Platform Quick Start Module +// Additional Platform Quick Start Module // ===================================================== -// Platform data loaded from JSON files (generated by gen_ecosystem_platform.py) +// Platform data loaded from JSON files (generated by gen_additional_platform.py) var ecosystemPlatformData = {{ platformData }}; // Get platform IDs from loaded data @@ -18,42 +18,54 @@ var ecosystemOpts = { version: null }; -// Initialize ecosystem platform when document is ready +// Initialize additional platform when document is ready $(function() { - initEcosystemPlatform(); - generateComputePlatformOptions(); - disableUnsupportedEcosystemPlatforms(ecosystemOpts.os); + initAdditionalPlatform(); + initAdditionalPlatformDropdowns(); + disableUnsupportedAdditionalPlatforms(); }); -// Dynamically generate compute platform options from loaded JSON data -function generateComputePlatformOptions() { - var container = $('.compute-platform'); - var count = ecosystemPlatformIds.length; - var colClass = count === 1 ? 'col-md-12' : - count === 2 ? 'col-md-6' : - count === 3 ? 'col-md-4' : 'col-md-3'; - +// Populate compute platform dropdown and version dropdown +function initAdditionalPlatformDropdowns() { + var platformSelect = $('#compute-platform-select'); + if (!platformSelect.length) return; + ecosystemPlatformIds.forEach(function(platformId) { var platform = ecosystemPlatformData[platformId]; - var displayName = platform ? (platform.name + ' (' + platform.vendor + ')') : platformId.toUpperCase(); - var optionHtml = '
' + - '
' + displayName + '
' + - '
'; - container.append(optionHtml); + if (!platform) return; + var displayName = platform.name + ' (' + platform.vendor + ')'; + platformSelect.append($('').prop('disabled', true); + $('#command').html('Select a compute platform to see the installation command.'); + return; + } + + // Check if supported on current OS var supportedOS = getSupportedOS(platformId); if (!supportedOS.includes(ecosystemOpts.os)) { - // Platform not supported, don't select it + ecosystemOpts.platform = null; + ecosystemOpts.version = null; + $(this).val(''); + $('#version-select').html('').prop('disabled', true); + $('#command').html('' + ecosystemPlatformData[platformId].name + ' is not supported on ' + ecosystemOpts.os + ''); return; } - - selectEcosystemPlatform(platformId); + + selectAdditionalPlatform(platformId); + }); + + // Bind version change + $('#version-select').on('change', function() { + ecosystemOpts.version = $(this).val(); + updateEcosystemCommand(); }); } @@ -61,8 +73,7 @@ function generateComputePlatformOptions() { function getSupportedOS(platformId) { var platform = ecosystemPlatformData[platformId]; if (!platform) return []; - - // Extract OS from both stable and preview + var osSet = new Set(); ['stable', 'preview'].forEach(function(build) { if (platform[build]) { @@ -96,39 +107,38 @@ function getAvailableVersions(platformId, os, build, pm, language) { } // Disable compute platforms not supported on selected OS -function disableUnsupportedEcosystemPlatforms(os) { - $('.compute-platform-option').each(function() { - var platformId = this.id; +function disableUnsupportedAdditionalPlatforms() { + $('#compute-platform-select option').each(function() { + var platformId = $(this).val(); + if (!platformId) return; // skip the placeholder option + var supportedOS = getSupportedOS(platformId); - var isSupported = supportedOS.includes(os); - - // Apply or remove strikethrough style - this.style.textDecoration = isSupported ? "" : "line-through"; - - // Add disabled class for visual feedback + var isSupported = supportedOS.includes(ecosystemOpts.os); + if (isSupported) { - $(this).removeClass('disabled-platform'); + $(this).css('text-decoration', ''); + $(this).prop('disabled', false); } else { - $(this).addClass('disabled-platform'); + $(this).css('text-decoration', 'line-through'); + $(this).prop('disabled', true); } }); - + // If currently selected platform is not supported on new OS, deselect it if (ecosystemOpts.platform) { var supportedOS = getSupportedOS(ecosystemOpts.platform); - if (!supportedOS.includes(os)) { + if (!supportedOS.includes(ecosystemOpts.os)) { ecosystemOpts.platform = null; ecosystemOpts.version = null; - $('.compute-platform-option').removeClass('selected'); - $('#version-row').hide(); - $('.version-heading').hide(); + $('#compute-platform-select').val(''); + $('#version-select').html('').prop('disabled', true); $('#command').html('Select a compute platform to see the installation command.'); } } } -// Initialize all click events -function initEcosystemPlatform() { +// Initialize all click events for build/os/package/language blocks +function initAdditionalPlatform() { // PyTorch Build $('.pytorch-build > .option').on('click', function() { $('.pytorch-build > .option').removeClass('selected'); @@ -137,94 +147,116 @@ function initEcosystemPlatform() { updateEcosystemVersions(); updateEcosystemCommand(); }); - + // OS - with platform support check $('.os-ecosystem > .option').on('click', function() { $('.os-ecosystem > .option').removeClass('selected'); $(this).addClass('selected'); ecosystemOpts.os = this.id; - - // Update platform strikethrough based on OS - disableUnsupportedEcosystemPlatforms(this.id); - + + disableUnsupportedAdditionalPlatforms(); updateEcosystemVersions(); updateEcosystemCommand(); }); - + // Package - with language binding $('.package-ecosystem > .option').on('click', function() { var packageId = this.id; - + $('.package-ecosystem > .option').removeClass('selected'); $(this).addClass('selected'); ecosystemOpts.pm = packageId; - + // Package-Language binding: pip/source -> python, libtorch -> cpp if (packageId === 'libtorch') { $('.language-ecosystem > .option').removeClass('selected'); $('#cpp').addClass('selected'); ecosystemOpts.language = 'cpp'; } else { - // pip or source -> python $('.language-ecosystem > .option').removeClass('selected'); $('#python').addClass('selected'); ecosystemOpts.language = 'python'; } - + updateEcosystemVersions(); updateEcosystemCommand(); }); - + // Language - with package binding $('.language-ecosystem > .option').on('click', function() { var languageId = this.id; - + $('.language-ecosystem > .option').removeClass('selected'); $(this).addClass('selected'); ecosystemOpts.language = languageId; - - // Package-Language binding: python -> pip/source, cpp -> libtorch + + // Package-Language binding: python -> pip, cpp -> libtorch if (languageId === 'cpp') { $('.package-ecosystem > .option').removeClass('selected'); $('#libtorch').addClass('selected'); ecosystemOpts.pm = 'libtorch'; } else { - // python -> pip $('.package-ecosystem > .option').removeClass('selected'); $('#pip').addClass('selected'); ecosystemOpts.pm = 'pip'; } - + updateEcosystemVersions(); updateEcosystemCommand(); }); } -// Select ecosystem platform and show versions -function selectEcosystemPlatform(platformId) { +// Select ecosystem platform and populate version dropdown +function selectAdditionalPlatform(platformId) { ecosystemOpts.platform = platformId; ecosystemOpts.version = null; - - // Update UI - $('.compute-platform-option').removeClass('selected'); - $('#' + platformId).addClass('selected'); - - // Show version row - $('#version-row').show(); - $('.version-heading').show(); - - // Load versions - updateEcosystemVersions(); + + // Populate version dropdown + populateVersionSelect(); updateEcosystemCommand(); } -// Update version options based on current selections +// Populate version select dropdown based on current selections +function populateVersionSelect() { + var versionSelect = $('#version-select'); + if (!versionSelect.length) return; + + versionSelect.html(''); + + if (!ecosystemOpts.platform) { + versionSelect.prop('disabled', true); + return; + } + + var versions = getAvailableVersions( + ecosystemOpts.platform, + ecosystemOpts.os, + ecosystemOpts.build, + ecosystemOpts.pm, + ecosystemOpts.language + ); + + if (versions.length === 0) { + versionSelect.prop('disabled', true); + $('#command').html('No versions available for this configuration'); + return; + } + + versions.forEach(function(version) { + versionSelect.append($(''); + if (versions.length === 0) { + versionSelect.prop('disabled', true); $('#command').html('No versions available for this configuration'); return; } - + versions.forEach(function(version) { - var colClass = versions.length === 1 ? 'col-md-12' : - versions.length === 2 ? 'col-md-6' : 'col-md-4'; - var optionHtml = '
' + - '
' + version + '
' + - '
'; - row.append(optionHtml); + versionSelect.append($('