Skip to content

Commit fab744a

Browse files
committed
fix: tgi image uri unit tests
1 parent 2f86ad9 commit fab744a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/unit/sagemaker/image_uris/test_huggingface_llm.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from __future__ import absolute_import
1414

1515
import pytest
16+
from packaging import version
1617

1718
from sagemaker.huggingface import get_huggingface_llm_image_uri
1819
from tests.unit.sagemaker.image_uris import expected_uris, conftest
@@ -72,10 +73,29 @@ def test_huggingface_uris(load_config):
7273
VERSIONS = load_config["inference"]["versions"]
7374
device = load_config["inference"]["processors"][0]
7475
backend = "huggingface-neuronx" if device == "inf2" else "huggingface"
76+
77+
# Fail if device is not in mapping
78+
if device not in HF_VERSIONS_MAPPING:
79+
raise ValueError(f"Device {device} not found in HF_VERSIONS_MAPPING")
80+
81+
# Get highest version for the device
82+
highest_version = max(HF_VERSIONS_MAPPING[device].keys(), key=lambda x: version.parse(x))
83+
7584
for version in VERSIONS:
7685
ACCOUNTS = load_config["inference"]["versions"][version]["registries"]
7786
for region in ACCOUNTS.keys():
7887
uri = get_huggingface_llm_image_uri(backend, region=region, version=version)
88+
89+
# Skip only if test version is higher than highest known version.
90+
# There's now automation to add new TGI releases to image_uri_config directory
91+
# that doesn't involve a human raising a PR.
92+
if version.parse(version) > version.parse(highest_version):
93+
print(
94+
f"Skipping test for version {test_version} as it is higher than the highest known version {highest_version}. "
95+
"There is automation that now updates the image_uri_config without a human raising a PR."
96+
)
97+
continue
98+
7999
expected = expected_uris.huggingface_llm_framework_uri(
80100
"huggingface-pytorch-tgi-inference",
81101
ACCOUNTS[region],

0 commit comments

Comments
 (0)