Skip to content

Conversation

@kumar-shivam-ranjan
Copy link
Contributor

@kumar-shivam-ranjan kumar-shivam-ranjan commented Oct 16, 2024

This PR intends to add delete/edit support for registered models along with delete/deactivate/activate support for model deployment

MD APIs

Screenshot 2024-10-16 at 4 04 23 PM Screenshot 2024-10-16 at 4 07 02 PM Screenshot 2024-10-16 at 4 08 31 PM

Delete registered model

Screenshot 2024-10-16 at 10 11 48 PM

Edit registered unverified model

Screenshot 2024-10-16 at 10 12 05 PM

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 16, 2024
@kumar-shivam-ranjan kumar-shivam-ranjan changed the title Adding delete support for model deployment and registered models Adding delete/activate/deactivate support for model deployment and registered models Oct 16, 2024
Copy link
Member

@VipulMascarenhas VipulMascarenhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a few comments. In addition to those, can you add unit tests?
and run pre-commit hook to fix formatting issues?

If you haven't set it up, use:

pip install pre-commit or brew install pre-commit or conda install pre-commit
run pre-commit install

ruff might not let you commit **args and **kwargs methods issue that we've used generously, you can use --no-verify for that until we add a fix.

)
url_parse = urlparse(self.request.path)
paths = url_parse.path.strip("/")
if paths.startswith("aqua/deployments/activate"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this path be aqua/deployments/<model_deployment_id>/activate? Same comment about deactivate as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

raise HTTPError(400, Errors.NO_INPUT_DATA)

inference_container=input_data.get('inference_container')
if inference_container is not None and inference_container not in [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this validation is fine now since we have SMCs, but we'll have to remove once we use BYOC (we're working on a POC for embeddings). If we need to keep this, can we not hardcode the list of acceptable containers here, instead read from container_index?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us remove this validation. If we decide to have this validation, let us wait till SMC listing API is available. Adding hardcoded list inside ADS code base can be limiting if we plan to add new SMC on the fly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@telemetry(entry_point="plugin=model&action=delete", name="aqua")
def delete_registered_model(self,model_id):
ds_model=DataScienceModel.from_id(model_id)
is_registered_model=ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM,None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to extend this to fine-tuned model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. This method now supports deletion of both registered and finetuned models

"""
ds_model=DataScienceModel.from_id(id)
if ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM,None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as above: can we allow user to edit deployment container for FT model?

Copy link
Contributor Author

@kumar-shivam-ranjan kumar-shivam-ranjan Oct 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editing FT model is not supported as of now. only deletion of FT models as per @mayoor 's comment

except Exception as ex:
raise AquaRuntimeError(f"The given model already doesn't support finetuning: {ex}")

custom_metadata_list.remove("modelDescription")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelDescription is required for model by reference - can you comment here why this metadata is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelDescription key had boolean value instead of string in custom metadata. editing model with modelDescription key in custom metadata required us to convert boolean to string which i though is additional not so useful step. Removing this key won't have any affect since as per MBR , this key is immutable and won't actually be removed or deleted.

The inference container family name
enable_finetuning: str
Flag to enable or disable finetuning over the model. Defaults to None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add task to docstrings parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

custom_metadata_list=updated_custom_metadata_list,
freeform_tags=freeform_tags
)
return self.ds_client.update_model(id,update_model_details).data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we reuse update_model() from app.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


custom_metadata_list.remove("modelDescription")
if task:
freeform_tags.update({"task":task})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use Tags.TASK instead?


@telemetry(entry_point="plugin=deployment&action=delete", name="aqua")
def delete(self,model_deployment_id:str):
return self.ds_client.delete_model_deployment(model_deployment_id=model_deployment_id).data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asking for my understanding - is this an async process or will this wait till MD is deleted? Same comment for activating and deactivating model.
For evaluation delete/cancel - we had to add additional wrapper to handle the wait time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be async only just like delete/cancel evals.

if not input_data:
raise HTTPError(400, Errors.NO_INPUT_DATA)

inference_container=input_data.get('inference_container')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use pre-commit hook and ruff formatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update

Copy link
Member

@VipulMascarenhas VipulMascarenhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good, can you please add a few unit tests?

@kumar-shivam-ranjan kumar-shivam-ranjan merged commit a2abc5c into feature/aqua-v1.0.5 Oct 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants