Skip to content

Commit a80395a

Browse files
committedApr 8, 2025·
Removing from_container_index method
1 parent 3ed30fa commit a80395a

File tree

2 files changed

+12
-92
lines changed

2 files changed

+12
-92
lines changed
 

‎ads/aqua/config/container_config.py

+11-90
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from oci.data_science.models import ContainerSummary
88
from pydantic import Field
99

10-
from ads.aqua.common.entities import ContainerSpec
1110
from ads.aqua.config.utils.serializer import Serializable
1211
from ads.aqua.constants import (
1312
SERVICE_MANAGED_CONTAINER_URI_SCHEME,
@@ -185,24 +184,31 @@ def from_service_config(
185184
0
186185
].additional_configurations.get(
187186
"MODEL_DEPLOY_PREDICT_ENDPOINT", UNKNOWN
188-
),
187+
)
188+
},
189+
{
189190
"MODEL_DEPLOY_HEALTH_ENDPOINT": container.workload_configuration_details_list[
190191
0
191192
].additional_configurations.get(
192193
"MODEL_DEPLOY_HEALTH_ENDPOINT", UNKNOWN
193-
),
194+
)
195+
},
196+
{
194197
"MODEL_DEPLOY_ENABLE_STREAMING": container.workload_configuration_details_list[
195198
0
196199
].additional_configurations.get(
197200
"MODEL_DEPLOY_ENABLE_STREAMING", UNKNOWN
198-
),
201+
)
202+
},
203+
{
199204
"PORT": container.workload_configuration_details_list[
200205
0
201206
].additional_configurations.get("PORT", ""),
202207
"HEALTH_CHECK_PORT": container.workload_configuration_details_list[
203208
0
204209
].additional_configurations.get("HEALTH_CHECK_PORT", UNKNOWN),
205-
}
210+
},
211+
{},
206212
]
207213
container_spec = AquaContainerConfigSpec(
208214
cli_param=container.workload_configuration_details_list[0].cmd,
@@ -239,88 +245,3 @@ def from_service_config(
239245
return cls(
240246
inference=inference_items, finetune=finetune_items, evaluate=evaluate_items
241247
)
242-
243-
@classmethod
244-
def from_container_index_json(
245-
cls,
246-
config: Dict,
247-
enable_spec: Optional[bool] = False,
248-
) -> "AquaContainerConfig":
249-
"""
250-
Creates an AquaContainerConfig instance from a container index JSON.
251-
252-
Parameters
253-
----------
254-
config (Optional[Dict]): The container index JSON.
255-
enable_spec (Optional[bool]): If True, fetch container specification details.
256-
257-
Returns
258-
-------
259-
AquaContainerConfig: The constructed container configuration.
260-
"""
261-
# TODO: Return this logic back if necessary in the next iteraion.
262-
# if not config:
263-
# config = get_container_config()
264-
inference_items: Dict[str, AquaContainerConfigItem] = {}
265-
finetune_items: Dict[str, AquaContainerConfigItem] = {}
266-
evaluate_items: Dict[str, AquaContainerConfigItem] = {}
267-
268-
for container_type, containers in config.items():
269-
if isinstance(containers, list):
270-
for container in containers:
271-
platforms = container.get("platforms", [])
272-
model_formats = container.get("modelFormats", [])
273-
usages = container.get("usages", [])
274-
container_spec = (
275-
config.get(ContainerSpec.CONTAINER_SPEC, {}).get(
276-
container_type, {}
277-
)
278-
if enable_spec
279-
else None
280-
)
281-
container_item = AquaContainerConfigItem(
282-
name=container.get("name", ""),
283-
version=container.get("version", ""),
284-
display_name=container.get(
285-
"displayName", container.get("version", "")
286-
),
287-
family=container_type,
288-
platforms=platforms,
289-
model_formats=model_formats,
290-
usages=usages,
291-
spec=(
292-
AquaContainerConfigSpec(
293-
cli_param=container_spec.get(
294-
ContainerSpec.CLI_PARM, ""
295-
),
296-
server_port=container_spec.get(
297-
ContainerSpec.SERVER_PORT, ""
298-
),
299-
health_check_port=container_spec.get(
300-
ContainerSpec.HEALTH_CHECK_PORT, ""
301-
),
302-
env_vars=container_spec.get(ContainerSpec.ENV_VARS, []),
303-
restricted_params=container_spec.get(
304-
ContainerSpec.RESTRICTED_PARAMS, []
305-
),
306-
)
307-
if container_spec
308-
else None
309-
),
310-
)
311-
if container.get("type").lower() == "inference":
312-
inference_items[container_type] = container_item
313-
elif (
314-
container.get("type").lower() == "fine-tune"
315-
or container_type == "odsc-llm-fine-tuning"
316-
):
317-
finetune_items[container_type] = container_item
318-
elif (
319-
container.get("type").lower() in ("evaluation", "evaluate")
320-
or container_type == "odsc-llm-evaluate"
321-
):
322-
evaluate_items[container_type] = container_item
323-
324-
return cls(
325-
inference=inference_items, finetune=finetune_items, evaluate=evaluate_items
326-
)

‎ads/aqua/modeldeployment/deployment.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ def _create(
468468
env_var.update({"BASE_MODEL_FILE": f"{model_file}"})
469469
tags.update({Tags.MODEL_ARTIFACT_FILE: model_file})
470470

471-
# todo: use AquaContainerConfig.from_container_index_json instead.
472471
# Fetch the startup cli command for the container
473472
# container_index.json will have "containerSpec" section which will provide the cli params for
474473
# a given container family
@@ -521,9 +520,9 @@ def _create(
521520
if params:
522521
env_var.update({"PARAMS": params})
523522
env_vars = container_spec.env_vars if container_spec else []
524-
env_vars = [{k: v} for env in env_vars for k, v in env.items() if v]
525523
for env in env_vars:
526524
if isinstance(env, dict):
525+
env = {k: v for k, v in env.items() if v}
527526
for key, _ in env.items():
528527
if key not in env_var:
529528
env_var.update(env)

0 commit comments

Comments
 (0)
Please sign in to comment.