Skip to content

Commit 9cefbb7

Browse files
Adding return type and type hinting for create_defined_metadata_artifact
1 parent 1861f25 commit 9cefbb7

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

ads/aqua/model/model.py

+8-17
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,9 @@ def create_defined_metadata_artifact(
10701070
metadata_key: str,
10711071
path_type: MetadataArtifactPathType,
10721072
artifact_path_or_content: str,
1073-
):
1073+
) -> None:
10741074
"""
1075-
Creates defined metadata artifact for the given model
1075+
Creates defined metadata artifact for the registered unverified model
10761076
10771077
Args:
10781078
model_id: str
@@ -1084,22 +1084,13 @@ def create_defined_metadata_artifact(
10841084
artifact_path_or_content: str
10851085
It can be local path or oss path or the actual content itself
10861086
Returns:
1087-
The model defined metadata artifact creation info.
1088-
Example:
1089-
{
1090-
'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
1091-
'opc-request-id': 'E4F7',
1092-
'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
1093-
'X-Content-Type-Options': 'nosniff',
1094-
'Content-Length': '4029958',
1095-
'Vary': 'Origin',
1096-
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
1097-
'status': 204
1098-
}
1099-
1087+
None
11001088
"""
11011089

11021090
ds_model = DataScienceModel.from_id(model_id)
1091+
oci_aqua = ds_model.freeform_tags.get(Tags.AQUA_TAG, None)
1092+
if not oci_aqua:
1093+
raise AquaRuntimeError(f"Target model {model_id} is not an Aqua model.")
11031094
is_registered_model = ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM, None)
11041095
is_verified_model = ds_model.freeform_tags.get(
11051096
Tags.AQUA_SERVICE_MODEL_TAG, None
@@ -1113,11 +1104,11 @@ def create_defined_metadata_artifact(
11131104
)
11141105
except Exception as ex:
11151106
raise AquaRuntimeError(
1116-
f"Error occurred in creating defined metadata artifact for model: {model_id}: {ex}"
1107+
f"Error occurred in creating defined metadata artifact for model {model_id}: {ex}"
11171108
) from ex
11181109
else:
11191110
raise AquaRuntimeError(
1120-
f"Cannot create defined metadata artifact for model: {model_id}"
1111+
f"Cannot create defined metadata artifact for model {model_id}"
11211112
)
11221113

11231114
def _create_model_catalog_entry(

0 commit comments

Comments
 (0)