|
5 | 5 | from _pytest.fixtures import FixtureRequest |
6 | 6 | from kubernetes.dynamic import DynamicClient |
7 | 7 | from ocp_resources.config_map import ConfigMap |
8 | | -from ocp_resources.gateway import Gateway |
9 | 8 | from ocp_resources.inference_service import InferenceService |
10 | 9 | from ocp_resources.namespace import Namespace |
11 | 10 | from ocp_resources.persistent_volume_claim import PersistentVolumeClaim |
|
14 | 13 | from ocp_resources.service_account import ServiceAccount |
15 | 14 | from ocp_resources.serving_runtime import ServingRuntime |
16 | 15 | from ocp_resources.storage_class import StorageClass |
17 | | -from ocp_resources.llm_inference_service import LLMInferenceService |
18 | 16 | from ocp_resources.data_science_cluster import DataScienceCluster |
19 | 17 | from ocp_resources.cluster_service_version import ClusterServiceVersion |
20 | 18 | from kubernetes.dynamic.exceptions import ResourceNotFoundError |
|
40 | 38 | from utilities.constants import ( |
41 | 39 | ModelAndFormat, |
42 | 40 | ) |
43 | | -from utilities.llmd_utils import create_llmd_gateway, create_llmisvc |
44 | 41 | from utilities.inference_utils import create_isvc |
45 | | -from utilities.llmd_constants import ( |
46 | | - LLMDGateway, |
47 | | - ModelStorage, |
48 | | - ContainerImages, |
49 | | -) |
50 | 42 | from utilities.infra import ( |
51 | 43 | s3_endpoint_secret, |
52 | 44 | update_configmap_data, |
53 | 45 | ) |
54 | | -from utilities.constants import Timeout |
55 | 46 | from utilities.serving_runtime import ServingRuntimeFromTemplate |
56 | 47 |
|
57 | 48 | LOGGER = get_logger(name=__name__) |
58 | 49 |
|
59 | 50 |
|
60 | | -# LLMD Fixtures |
61 | | -@pytest.fixture(scope="class") |
62 | | -def llmd_inference_service( |
63 | | - request: FixtureRequest, |
64 | | - admin_client: DynamicClient, |
65 | | - unprivileged_model_namespace: Namespace, |
66 | | -) -> Generator[LLMInferenceService, None, None]: |
67 | | - if isinstance(request.param, str): |
68 | | - name_suffix = request.param |
69 | | - kwargs = {} |
70 | | - else: |
71 | | - name_suffix = request.param.get("name_suffix", "basic") |
72 | | - kwargs = {k: v for k, v in request.param.items() if k != "name_suffix"} |
73 | | - |
74 | | - service_name = kwargs.get("name", f"llm-{name_suffix}") |
75 | | - |
76 | | - if "llmd_gateway" in request.fixturenames: |
77 | | - request.getfixturevalue(argname="llmd_gateway") |
78 | | - container_resources = kwargs.get( |
79 | | - "container_resources", |
80 | | - { |
81 | | - "limits": {"cpu": "2", "memory": "16Gi"}, |
82 | | - "requests": {"cpu": "500m", "memory": "12Gi"}, |
83 | | - }, |
84 | | - ) |
85 | | - |
86 | | - create_kwargs = { |
87 | | - "client": admin_client, |
88 | | - "name": service_name, |
89 | | - "namespace": unprivileged_model_namespace.name, |
90 | | - "storage_uri": kwargs.get("storage_uri", ModelStorage.TINYLLAMA_OCI), |
91 | | - "container_image": kwargs.get("container_image", ContainerImages.VLLM_CPU), |
92 | | - "container_resources": container_resources, |
93 | | - "wait": True, |
94 | | - "timeout": Timeout.TIMEOUT_15MIN, |
95 | | - **{k: v for k, v in kwargs.items() if k != "name"}, |
96 | | - } |
97 | | - |
98 | | - with create_llmisvc(**create_kwargs) as llm_service: |
99 | | - yield llm_service |
100 | | - |
101 | | - |
102 | | -@pytest.fixture(scope="session") |
103 | | -def gateway_namespace(admin_client: DynamicClient) -> str: |
104 | | - return LLMDGateway.DEFAULT_NAMESPACE |
105 | | - |
106 | | - |
107 | | -@pytest.fixture(scope="session") |
108 | | -def shared_llmd_gateway( |
109 | | - admin_client: DynamicClient, |
110 | | - gateway_namespace: str, |
111 | | -) -> Generator[Gateway, None, None]: |
112 | | - gateway_class_name = "data-science-gateway-class" |
113 | | - |
114 | | - with create_llmd_gateway( |
115 | | - client=admin_client, |
116 | | - namespace=gateway_namespace, |
117 | | - gateway_class_name=gateway_class_name, |
118 | | - wait_for_condition=True, |
119 | | - timeout=Timeout.TIMEOUT_5MIN, |
120 | | - teardown=True, |
121 | | - ) as gateway: |
122 | | - yield gateway |
123 | | - |
124 | | - |
125 | | -@pytest.fixture(scope="class") |
126 | | -def llmd_gateway(shared_llmd_gateway: Gateway) -> Gateway: |
127 | | - return shared_llmd_gateway |
128 | | - |
129 | | - |
130 | 51 | @pytest.fixture(scope="class") |
131 | 52 | def models_endpoint_s3_secret( |
132 | 53 | unprivileged_client: DynamicClient, |
|
0 commit comments