Files
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

86 lines
2.9 KiB
Python

# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
import os
import sys
from pathlib import Path
import pytest
sys.path.insert(0, os.fspath(Path(__file__).parent.parent))
from manage import S3Index, S3Object, _make_list_prefix, update_pep503_index
# ---------------------------------------------------------------------------
# _make_list_prefix
# ---------------------------------------------------------------------------
@pytest.mark.parametrize(
"prefix, package_name, expected",
[
("v4/whl", "torch", "v4/whl/torch-"),
("v4/whl", "amd_torch_device_gfx942", "v4/whl/amd_torch_device_gfx942-"),
("v4/whl", "torchaudio", "v4/whl/torchaudio-"),
("v4/whl", None, "v4/whl"),
("v2/gfx94X-dcgpu", None, "v2/gfx94X-dcgpu"),
# Empty string must not narrow the prefix; treated as full sweep.
("v4/whl", "", "v4/whl"),
],
)
def test_make_list_prefix(prefix: str, package_name: str | None, expected: str) -> None:
assert _make_list_prefix(prefix, package_name) == expected
def test_update_pep503_index_rejects_package_name_with_update_root_index() -> None:
with pytest.raises(ValueError, match="package_name and update_root_index=True cannot be used together"):
update_pep503_index(prefix="v4/whl", package_name="torch", update_root_index=True)
def test_make_list_prefix_torch_does_not_match_torchaudio() -> None:
# The hyphen delimiter ensures torch- cannot match torchaudio- wheels.
prefix = _make_list_prefix("v4/whl", "torch")
assert not "torchaudio-2.10.0.whl".startswith(prefix.split("/")[-1] + "audio")
assert "torch-2.10.0.whl".startswith(prefix.split("/")[-1])
assert not "torchaudio-2.10.0.whl".startswith(prefix.split("/")[-1])
# ---------------------------------------------------------------------------
# S3Index.obj_to_package_name
# ---------------------------------------------------------------------------
def _make_obj(key: str) -> S3Object:
return S3Object(key=key, orig_key=key, checksum=None, size=None, pep658=None)
@pytest.mark.parametrize(
"key, expected",
[
(
"v4/whl/torch-2.10.0%2Brocm7.14.0a20260617-cp310-cp310-linux_x86_64.whl",
"torch",
),
(
"v4/whl/amd_torch_device_gfx942-2.10.0%2Brocm7.14.0a20260617-py3-none-linux_x86_64.whl",
"amd_torch_device_gfx942",
),
(
"v4/whl/torchaudio-2.10.0%2Brocm7.14.0a20260617-cp310-cp310-linux_x86_64.whl",
"torchaudio",
),
(
"v4/whl/torchvision-0.21.0%2Brocm7.14.0a20260617-cp312-cp312-linux_x86_64.whl",
"torchvision",
),
(
"v2/gfx94X-dcgpu/torch-2.10.0-cp310-cp310-linux_x86_64.whl",
"torch",
),
],
)
def test_obj_to_package_name(key: str, expected: str) -> None:
idx = S3Index([], prefix="v4/whl")
assert idx.obj_to_package_name(_make_obj(key)) == expected