Skip to content

Commit e579dd0

Browse files
authored
Merge branch 'r25.09' into mchornyi/TPRD-1684/remove-software-properties-common
2 parents c9745ce + 12ea5a3 commit e579dd0

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

python/openai/openai_frontend/engine/utils/triton.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import os
2929
import re
3030
from dataclasses import asdict, dataclass, field
31+
from pathlib import Path
3132
from typing import Iterable, List, Optional, Union
3233

3334
import numpy as np
@@ -356,13 +357,24 @@ def _get_guided_json_from_tool(
356357
def _get_vllm_lora_names(
357358
model_repository: str | list[str], model_name: str, model_version: int
358359
) -> None | List[str]:
360+
if (
361+
len(model_name) == 0
362+
or model_name.isspace()
363+
or "/" in model_name
364+
or "\\" in model_name
365+
):
366+
raise ValueError(
367+
f"Invalid model name: '{model_name}'. Model names must be valid file-system-path segment names."
368+
)
359369
lora_names = []
360370
repo_paths = model_repository
361371
if isinstance(repo_paths, str):
362372
repo_paths = [repo_paths]
363373
for repo_path in repo_paths:
364374
model_path = os.path.join(repo_path, model_name)
365-
if os.path.normpath(model_path) != model_path:
375+
if (not Path(model_path).is_relative_to(repo_path)) or (
376+
os.path.normpath(model_path) != model_path
377+
):
366378
raise ValueError(
367379
f"Invalid model name: '{model_name}'. Model names must be valid file-system-path segment names."
368380
)

python/openai/tests/test_lora.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,50 @@
2929
import shutil
3030
import unittest
3131

32+
import pytest
3233
from huggingface_hub import snapshot_download
3334
from openai import BadRequestError, NotFoundError
35+
from openai_frontend.engine.utils.triton import (
36+
_get_vllm_lora_names as get_vllm_lora_names,
37+
)
3438

3539
from .utils import OpenAIServer
3640

3741

42+
@pytest.mark.parametrize(
43+
"model_repository,model_name,expect_error",
44+
[
45+
("openai_model_repository", "", True), # Empty string as model name.
46+
("openai_model_repository", " ", True), # Whitespace-only model name.
47+
("openai_model_repository", "invalid/path", True),
48+
("openai_model_repository", "invalid\\path", True),
49+
("openai_model_repository", "../outside/repo", True),
50+
("openai_model_repository", "../test_models/identity_py", True),
51+
("test_models", "../test_models/identity_py", True),
52+
("test_models", "identity_py", False),
53+
("test_models", "mock_llm", False),
54+
],
55+
)
56+
def test_get_vllm_lora_name(model_repository: str, model_name: str, expect_error: bool):
57+
try:
58+
get_vllm_lora_names(model_repository, model_name, 1)
59+
except ValueError as e:
60+
if expect_error:
61+
assert (
62+
f"Invalid model name: '{model_name}'. Model names must be valid file-system-path segment names."
63+
== str(e)
64+
)
65+
else:
66+
raise pytest.fail(
67+
f"(model_repository='{model_repository}', model_name='{model_name}') raised ValueError unexpectedly: {e}"
68+
)
69+
else:
70+
if expect_error:
71+
raise pytest.fail(
72+
f"(model_repository='{model_repository}', model_name='{model_name}') did not raise ValueError as expected."
73+
)
74+
75+
3876
def is_vllm_installed():
3977
try:
4078
import vllm as _

qa/L0_backend_python/setup_python_enviroment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ echo "python environment 3.${PYTHON_ENV_VERSION}"
9999
# copy the stub out to /opt/tritonserver/backends/python/triton_python_backend_stub
100100
cp python_backend/builddir/triton_python_backend_stub /opt/tritonserver/backends/python/triton_python_backend_stub
101101
# Set up environment and stub for each test
102+
apt-get update -qq && apt-get install -y software-properties-common
102103
add-apt-repository ppa:deadsnakes/ppa -y
103104
apt-get update && apt-get -y install \
104105
"python3.${PYTHON_ENV_VERSION}-dev" \

0 commit comments

Comments
 (0)