There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DeleteModel
with an AWS SDK
The following code example shows how to use DeleteModel
.
For more information, see Deleting a model.
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. 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
-
For API details, see DeleteModel in AWS SDK for Python (Boto3) API Reference.
-
DeleteDataset
DeleteProject