Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DeleteModel
dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanDeleteModel
.
Untuk informasi selengkapnya, lihat Menghapus model.
- Python
-
- SDKuntuk Python (Boto3)
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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