-
Notifications
You must be signed in to change notification settings - Fork 59
Adding inference container URI for edit model handler #1030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2295252
3aedb48
a95a678
5b3a316
16b7ace
c6f87ec
3a9fa5b
f196331
8edce5c
e8d366f
557509e
1ba166a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| from tornado.web import HTTPError | ||
|
|
||
| from ads.aqua.common.decorator import handle_exceptions | ||
| from ads.aqua.common.enums import InferenceContainerTypeFamily | ||
| from ads.aqua.common.errors import AquaRuntimeError, AquaValueError | ||
| from ads.aqua.common.utils import ( | ||
| get_hf_model_info, | ||
|
|
@@ -163,10 +164,13 @@ def put(self, id): | |
| raise HTTPError(400, Errors.NO_INPUT_DATA) | ||
|
|
||
| inference_container = input_data.get("inference_container") | ||
| inference_container_uri = input_data.get("inference_container_uri") | ||
| inference_containers = AquaModelApp.list_valid_inference_containers() | ||
| if ( | ||
| inference_container is not None | ||
| and inference_container not in inference_containers | ||
| and inference_container | ||
|
||
| != InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY | ||
| ): | ||
| raise HTTPError( | ||
| 400, Errors.INVALID_VALUE_OF_PARAMETER.format("inference_container") | ||
|
|
@@ -176,7 +180,13 @@ def put(self, id): | |
| task = input_data.get("task") | ||
| app = AquaModelApp() | ||
| self.finish( | ||
| app.edit_registered_model(id, inference_container, enable_finetuning, task) | ||
| app.edit_registered_model( | ||
| id, | ||
| inference_container, | ||
| inference_container_uri, | ||
| enable_finetuning, | ||
| task, | ||
| ) | ||
| ) | ||
| app.clear_model_details_cache(model_id=id) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -377,7 +377,9 @@ def delete_model(self, model_id): | |
| ) | ||
|
|
||
| @telemetry(entry_point="plugin=model&action=delete", name="aqua") | ||
|
||
| def edit_registered_model(self, id, inference_container, enable_finetuning, task): | ||
| def edit_registered_model( | ||
| self, id, inference_container, inference_container_uri, enable_finetuning, task | ||
| ): | ||
| """Edits the default config of unverified registered model. | ||
|
|
||
| Parameters | ||
|
|
@@ -386,6 +388,8 @@ def edit_registered_model(self, id, inference_container, enable_finetuning, task | |
| The model OCID. | ||
| inference_container: str. | ||
| The inference container family name | ||
| inference_container_uri: str | ||
| The inference container uri for embedding models | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s it only for embedding models?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes as per now , we accept inference container URI for embedding models only |
||
| enable_finetuning: str | ||
| Flag to enable or disable finetuning over the model. Defaults to None | ||
| task: | ||
|
|
@@ -407,13 +411,40 @@ def edit_registered_model(self, id, inference_container, enable_finetuning, task | |
| custom_metadata_list = ds_model.custom_metadata_list | ||
| freeform_tags = ds_model.freeform_tags | ||
| if inference_container: | ||
| custom_metadata_list.add( | ||
| key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER, | ||
| value=inference_container, | ||
| category=MetadataCustomCategory.OTHER, | ||
| description="Deployment container mapping for SMC", | ||
| replace=True, | ||
| ) | ||
| if ( | ||
| inference_container | ||
|
||
| == InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY | ||
| and inference_container_uri is None | ||
| ): | ||
| raise AquaRuntimeError( | ||
| f"Failed to edit model:{id}. Inference container URI must be provided." | ||
| ) | ||
| else: | ||
| custom_metadata_list.add( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to store this info in metadata? Can't it be extracted from MD?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This metadata contains deployment container. Via edit feature , user can edit/change deployment container as well. Hence , adding updated container to metadata.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However user can update deployment from console, and in this case the container stored on the model level will not match a real one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes but source of truth here should be model right , not the model deployment. |
||
| key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER, | ||
| value=inference_container, | ||
| category=MetadataCustomCategory.OTHER, | ||
| description="Deployment container mapping for SMC", | ||
| replace=True, | ||
| ) | ||
| if inference_container_uri: | ||
| if ( | ||
| inference_container | ||
| == InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY | ||
| or inference_container is None | ||
| ): | ||
| custom_metadata_list.add( | ||
| key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI, | ||
| value=inference_container_uri, | ||
| category=MetadataCustomCategory.OTHER, | ||
| description=f"Inference container URI for {ds_model.display_name}", | ||
| replace=True, | ||
| ) | ||
| else: | ||
| raise AquaRuntimeError( | ||
| f"Failed to edit model:{id}. Inference container URI can be edited only with TEI container." | ||
|
||
| ) | ||
|
|
||
| if enable_finetuning is not None: | ||
| if enable_finetuning.lower() == "true": | ||
| custom_metadata_list.add( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it always return a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes , either an empty list or list of valid containers from container_index.json stored in OSS bucket