文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeleteModel
搭配 a AWS SDK 使用
下列程式碼範例示範如何使用 DeleteModel
。
如需詳細資訊,請參閱刪除模型。
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 class Models: @staticmethod def delete_model(lookoutvision_client, project_name, model_version): """ Deletes a Lookout for Vision model. The model must first be stopped and can't be in training. :param lookoutvision_client: A Boto3 Lookout for Vision client. :param project_name: The name of the project that contains the desired model. :param model_version: The version of the model that you want to delete. """ try: logger.info("Deleting model: %s", model_version) lookoutvision_client.delete_model( ProjectName=project_name, ModelVersion=model_version ) model_exists = True while model_exists: response = lookoutvision_client.list_models(ProjectName=project_name) model_exists = False for model in response["Models"]: if model["ModelVersion"] == model_version: model_exists = True if model_exists is False: logger.info("Model deleted") else: logger.info("Model is being deleted...") time.sleep(2) logger.info("Deleted Model: %s", model_version) except ClientError: logger.exception("Couldn't delete model.") raise
-
如需 API 詳細資訊,請參閱 DeleteModel AWS SDK for Python (Boto3) Word 參考中的 API。
-
DeleteDataset
DeleteProject