7
7
from oci .data_science .models import ContainerSummary
8
8
from pydantic import Field
9
9
10
+ from ads .aqua import logger
10
11
from ads .aqua .config .utils .serializer import Serializable
11
12
from ads .aqua .constants import (
12
13
SERVICE_MANAGED_CONTAINER_URI_SCHEME ,
@@ -168,50 +169,47 @@ def from_service_config(
168
169
container_type = container .family_name
169
170
usages = [x .upper () for x in container .usages ]
170
171
if "INFERENCE" in usages or "MULTI_MODEL" in usages :
172
+ # Extract additional configurations
173
+ additional_configurations = {}
174
+ try :
175
+ additional_configurations = (
176
+ container .workload_configuration_details_list [
177
+ 0
178
+ ].additional_configurations
179
+ )
180
+ except (AttributeError , IndexError ) as ex :
181
+ logger .debug (
182
+ "Failed to extract `additional_configurations` for container '%s': %s" ,
183
+ getattr (container , "container_name" , "<unknown>" ),
184
+ ex ,
185
+ )
186
+
171
187
container_item .platforms .append (
172
- container .workload_configuration_details_list [
173
- 0
174
- ].additional_configurations .get ("platforms" )
188
+ additional_configurations .get ("platforms" )
175
189
)
176
190
container_item .model_formats .append (
177
- container .workload_configuration_details_list [
178
- 0
179
- ].additional_configurations .get ("modelFormats" )
191
+ additional_configurations .get ("modelFormats" )
180
192
)
193
+
194
+ # Parse environment variables from `additional_configurations`.
195
+ # Only keys present in the configuration will be added to the result.
196
+ config_keys = {
197
+ "MODEL_DEPLOY_PREDICT_ENDPOINT" : UNKNOWN ,
198
+ "MODEL_DEPLOY_HEALTH_ENDPOINT" : UNKNOWN ,
199
+ "MODEL_DEPLOY_ENABLE_STREAMING" : UNKNOWN ,
200
+ "PORT" : UNKNOWN ,
201
+ "HEALTH_CHECK_PORT" : UNKNOWN ,
202
+ "VLLM_USE_V1" : UNKNOWN ,
203
+ }
204
+
181
205
env_vars = [
182
- {
183
- "MODEL_DEPLOY_PREDICT_ENDPOINT" : container .workload_configuration_details_list [
184
- 0
185
- ].additional_configurations .get (
186
- "MODEL_DEPLOY_PREDICT_ENDPOINT" , UNKNOWN
187
- )
188
- },
189
- {
190
- "MODEL_DEPLOY_HEALTH_ENDPOINT" : container .workload_configuration_details_list [
191
- 0
192
- ].additional_configurations .get (
193
- "MODEL_DEPLOY_HEALTH_ENDPOINT" , UNKNOWN
194
- )
195
- },
196
- {
197
- "MODEL_DEPLOY_ENABLE_STREAMING" : container .workload_configuration_details_list [
198
- 0
199
- ].additional_configurations .get (
200
- "MODEL_DEPLOY_ENABLE_STREAMING" , UNKNOWN
201
- )
202
- },
203
- {
204
- "PORT" : container .workload_configuration_details_list [
205
- 0
206
- ].additional_configurations .get ("PORT" , "" )
207
- },
208
- {
209
- "HEALTH_CHECK_PORT" : container .workload_configuration_details_list [
210
- 0
211
- ].additional_configurations .get ("HEALTH_CHECK_PORT" , UNKNOWN ),
212
- },
206
+ {key : additional_configurations .get (key , default )}
207
+ for key , default in config_keys .items ()
208
+ if key in additional_configurations
213
209
]
214
- container_spec = AquaContainerConfigSpec (
210
+
211
+ # Build container spec
212
+ container_item .spec = AquaContainerConfigSpec (
215
213
cli_param = container .workload_configuration_details_list [0 ].cmd ,
216
214
server_port = str (
217
215
container .workload_configuration_details_list [0 ].server_port
@@ -236,13 +234,14 @@ def from_service_config(
236
234
)
237
235
),
238
236
)
239
- container_item . spec = container_spec
237
+
240
238
if "INFERENCE" in usages or "MULTI_MODEL" in usages :
241
239
inference_items [container_type ] = container_item
242
240
if "FINE_TUNE" in usages :
243
241
finetune_items [container_type ] = container_item
244
242
if "EVALUATION" in usages :
245
243
evaluate_items [container_type ] = container_item
244
+
246
245
return cls (
247
246
inference = inference_items , finetune = finetune_items , evaluate = evaluate_items
248
247
)
0 commit comments