Skip to content

Commit 07483da

Browse files
review comments
1 parent be72643 commit 07483da

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

ads/aqua/common/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,13 @@ def get_container_image(
576576
A dict of allowed configs.
577577
"""
578578

579+
container_image = UNKNOWN
579580
config = config_file_name or get_container_config()
580581
config_file_name = service_config_path()
581582

582583
if container_type not in config:
583-
raise AquaValueError(
584-
f"{config_file_name} does not have config details for model: {container_type}"
585-
)
584+
return UNKNOWN
586585

587-
container_image = None
588586
mapping = config[container_type]
589587
versions = [obj["version"] for obj in mapping]
590588
# assumes numbered versions, update if `latest` is used
@@ -1149,7 +1147,7 @@ def validate_cmd_var(cmd_var: List[str], overrides: List[str]) -> List[str]:
11491147
common_keys = set(cmd_dict.keys()) & set(overrides_dict.keys())
11501148
if common_keys:
11511149
raise AquaValueError(
1152-
f"The following keys cannot be overridden: {', '.join(common_keys)}"
1150+
f"The following CMD input cannot be overridden for model deployment: {', '.join(common_keys)}"
11531151
)
11541152

11551153
combined_cmd_var = cmd_var + overrides

ads/aqua/modeldeployment/deployment.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -246,41 +246,41 @@ def create(
246246
model=aqua_model, container_family=container_family
247247
)
248248

249-
# todo: revisit this when TEI is added to SMC list. Currently, container_image_uri is ignored if container
250-
# family is SMC.
251-
if container_type_key == InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY:
252-
if not container_image_uri:
253-
try:
254-
container_image_uri = aqua_model.custom_metadata_list.get(
255-
AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME
256-
).value
257-
except ValueError as err:
258-
raise AquaValueError(
259-
f"{AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME} key is not available in the custom metadata "
260-
f"field. Either re-register the model with custom container URI, or set container_image_uri "
261-
f"parameter when creating this deployment."
262-
) from err
263-
249+
container_image_uri = container_image_uri or get_container_image(
250+
container_type=container_type_key
251+
)
252+
if not container_image_uri:
264253
try:
265-
cmd_var_string = aqua_model.custom_metadata_list.get(
266-
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME
254+
container_image_uri = aqua_model.custom_metadata_list.get(
255+
AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME
267256
).value
268257
except ValueError as err:
269258
raise AquaValueError(
270-
f"{AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME} key is not available in the custom metadata "
271-
f"field. Please check if the model was registered with {container_type_key} inference container."
259+
f"{AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME} key is not available in the custom metadata "
260+
f"field. Either re-register the model with custom container URI, or set container_image_uri "
261+
f"parameter when creating this deployment."
272262
) from err
263+
logging.info(
264+
f"Aqua Image used for deploying {aqua_model.id} : {container_image_uri}"
265+
)
266+
267+
try:
268+
cmd_var_string = aqua_model.custom_metadata_list.get(
269+
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME
270+
).value
273271
default_cmd_var = cmd_var_string.split(",")
274272
if default_cmd_var:
275273
cmd_var = validate_cmd_var(default_cmd_var, cmd_var)
276274
logging.info(f"CMD used for deploying {aqua_model.id} :{cmd_var}")
277-
else:
278-
# fetch image name from config
279-
container_image_uri = get_container_image(container_type=container_type_key)
280-
281-
logging.info(
282-
f"Aqua Image used for deploying {aqua_model.id} : {container_image_uri}"
283-
)
275+
except ValueError:
276+
logging.debug(
277+
f"CMD will be ignored for this deployment as {AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME} "
278+
f"key is not available in the custom metadata field for this model."
279+
)
280+
except Exception as e:
281+
logging.error(
282+
f"There was an issue processing CMD arguments. Error: {str(e)}"
283+
)
284284

285285
model_formats_str = aqua_model.freeform_tags.get(
286286
Tags.MODEL_FORMAT, ModelFormat.SAFETENSORS.value

tests/unitary/with_extras/aqua/test_deployment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def test_create_deployment_for_tei_byoc_embedding_model(
716716
mock_create.assert_called_with(
717717
model_id=TestDataset.MODEL_ID, compartment_id=None, project_id=None
718718
)
719-
mock_get_container_image.assert_not_called()
719+
mock_get_container_image.assert_called()
720720
mock_deploy.assert_called()
721721

722722
expected_attributes = set(AquaDeployment.__annotations__.keys())

0 commit comments

Comments
 (0)