Files
TheRock/build_tools/packaging/tests/download_python_packages_test.py
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

80 lines
2.6 KiB
Python

#!/usr/bin/env python
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Unit tests for package recognition in download_python_packages.py.
The JAX plugin/pjrt wheels embed the ROCm major version in their package name,
so these tests cover both the ROCm 7 and ROCm 10 spellings to make sure a ROCm
version bump does not silently drop the wheels from promotion.
"""
import os
import sys
import unittest
from pathlib import Path
sys.path.insert(0, os.fspath(Path(__file__).parent.parent))
from download_python_packages import (
categorize_package,
is_allowed_multi_arch_package,
)
JAX_ROCM7_WHEELS = [
"jax_rocm7_plugin-0.9.2+rocm7.15.0-cp312-cp312-manylinux_2_28_x86_64.whl",
"jax_rocm7_pjrt-0.9.2+rocm7.15.0-py3-none-manylinux_2_28_x86_64.whl",
]
JAX_ROCM10_WHEELS = [
"jax_rocm10_plugin-0.10.0+rocm10.0.0-cp313-cp313-manylinux_2_27_x86_64.whl",
"jax_rocm10_pjrt-0.10.0+rocm10.0.0-py3-none-manylinux_2_27_x86_64.whl",
]
class CategorizePackageTest(unittest.TestCase):
def test_jax_rocm7_wheels_are_promoted(self):
for filename in JAX_ROCM7_WHEELS:
with self.subTest(filename=filename):
self.assertEqual(categorize_package(filename), "promote")
def test_jax_rocm10_wheels_are_promoted(self):
for filename in JAX_ROCM10_WHEELS:
with self.subTest(filename=filename):
self.assertEqual(categorize_package(filename), "promote")
def test_jaxlib_is_still_promoted(self):
self.assertEqual(
categorize_package("jaxlib-0.9.2-cp312-cp312-manylinux_2_28_x86_64.whl"),
"promote",
)
def test_unrelated_jax_rocm_name_is_unknown(self):
# Only the plugin/pjrt wheels carry the ROCm major in their name; a
# majorless or unexpected variant should not be promoted silently.
self.assertEqual(
categorize_package("jax_rocm_plugin-0.10.0-py3-none-any.whl"),
"unknown",
)
class IsAllowedMultiArchPackageTest(unittest.TestCase):
def test_jax_rocm7_wheels_are_allowed(self):
for filename in JAX_ROCM7_WHEELS:
with self.subTest(filename=filename):
self.assertTrue(is_allowed_multi_arch_package(filename))
def test_jax_rocm10_wheels_are_allowed(self):
for filename in JAX_ROCM10_WHEELS:
with self.subTest(filename=filename):
self.assertTrue(is_allowed_multi_arch_package(filename))
def test_unknown_package_is_not_allowed(self):
self.assertFalse(
is_allowed_multi_arch_package("some_other_pkg-1.0-py3-none-any.whl")
)
if __name__ == "__main__":
unittest.main()