fromgoogle.cloudimportaiplatformdefdelete_model_sample(model_id:str,project:str,location:str):""" Delete a Model resource. Args: model_id: The ID of the model to delete. Parent resource name of the model is also accepted. project: The project. location: The region name. Returns None. """# Initialize the client.aiplatform.init(project=project,location=location)# Get the model with the ID 'model_id'. The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'model=aiplatform.Model(model_name=model_id)# Delete the model.model.delete()
删除模型版本
控制台
从 Google Cloud 控制台的 Vertex AI 部分,进入 Model Registry 页面。
fromgoogle.cloudimportaiplatformdefdelete_model_version_sample(model_id:str,version_id:str,project:str,location:str):""" Delete a Model version. Args: model_id: The ID of the model to delete. Parent resource name of the model is also accepted. version_id: The version ID or version alias of the model to delete. project: The project ID. location: The region name. Returns None. """# Initialize the client.aiplatform.init(project=project,location=location)# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'model_registry=aiplatform.models.ModelRegistry(model=model_id)# Delete the model version with the version 'version'.model_registry.delete_version(version=version_id)
fromtypingimportListfromgoogle.cloudimportaiplatformdefdelete_aliases_model_version_sample(model_id:str,version_aliases:List[str],version_id:str,project:str,location:str,):""" Delete aliases to a model version. Args: model_id: The ID of the model. version_aliases: The version aliases to assign. version_id: The version ID of the model to assign the aliases to. project: The project ID. location: The region name. Returns None. """# Initialize the client.aiplatform.init(project=project,location=location)# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'model_registry=aiplatform.models.ModelRegistry(model=model_id)# Remove the version aliases to the model version with the version 'version'.model_registry.remove_version_aliases(target_aliases=version_aliases,version=version_id)
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-04-02。"],[],[]]