简体   繁体   English

检查转录作业是否存在如果存在则删除它

[英]check if transcribe job exists if it exists delete it

Hello I'm using the aws cli with pyhon.您好,我正在使用带有 pyhon 的 aws cli。 I need to delete previous jobs from the transcription service to prevent a high invoice.我需要从转录服务中删除以前的工作以防止高额发票。 My problem remains when the script starts because yet there isn't any job, I need delete if it exist and if it doesn't exists do nothing.当脚本启动时我的问题仍然存在,因为还没有任何工作,如果它存在我需要删除,如果它不存在则什么也不做。

transcribe_client = boto3.client('transcribe', aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region_name=AWS_DEFAULT_REGION)
JOB_NAME = "Example-job"

 try:
   transcribe_client.delete_transcription_job(TranscriptionJobName=JOB_NAME)
 except ClientError as e:
   raise Exception( "boto3 client error el job doesnt exists: " + e.__str__())
 except Exception as e:
   raise Exception( "Unexpected error deleting job: " + e.__str__())

When the program starts it's throwing a exception because there isn't any job.程序启动时会抛出异常,因为没有任何工作。 I need to check if this exists and the delete it, and if this job doesn't exists do nothing and should not exists crashes.我需要检查它是否存在并删除它,如果这个作业不存在则什么也不做,不应该存在崩溃。

Also I don't know if this jobs has a price, if this jobs doesn't have cost/price I will generate many jobs with unique id and of this way I should prevent crashes.我也不知道这个工作是否有价格,如果这个工作没有成本/价格,我会生成许多具有唯一 ID 的工作,这样我应该可以防止崩溃。

any idea guys to solve this problem I will appreciate.解决这个问题的任何想法,我将不胜感激。 thanks so much.非常感谢。

You can call list_transcription_jobs to retrieve a list of transcription jobs that match the specified criteria, or a list of all transcription jobs if you don't specify criteria.您可以调用list_transcription_jobs来检索符合指定条件的转录作业列表,或者如果您未指定条件,则检索所有转录作业的列表。 You can then iterate over the results and decide which jobs need to be deleted.然后您可以遍历结果并决定需要删除哪些作业。

Alternatively, You can call get_transcription_job which, according to the docs, will throw TranscribeService.Client.exceptions.NotFoundException.或者,您可以调用get_transcription_job ,根据文档,这将抛出 TranscribeService.Client.exceptions.NotFoundException。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查该字段是否存在于 firestore 中? - How to check if the field exists in firestore? 检查表是否存在:Spark bigquery connector - Check if table exists: Spark bigquery connector 使用 Powershell 检查文件是否存在于 S3 中 - Check if File exists in S3 using Powershell 如何检查表是否存在于谷歌大查询中? - How to check if table exists in google big query? 检查 Firebase 实时数据库中是否存在条目(Python) - Check if entry exists in Firebase Realtime Databse (Python) 如何检查 firebase 数据库中是否存在唯一条目? - How to check if unique entry exists in firebase database or not? AWS Glue 中的简单 ETL 作业显示“文件已存在” - Simple ETL job in AWS Glue says "File Already Exists" 如何检查该字段在Firebase中是否存在,如果存在则打印其值,如果不存在则在Flutter中添加一个空值 - How to check whether the field exists in Firebase, if it exists then print its value, if it does not exist, then add it with an empty value in Flutter 检查组中是否存在值并将其分配给 BigQuery 中的所有组行 - Check if value exists in group and assign it to all rows of group in BigQuery 在发送 email 之前,检查 SendGrid 中是否确实存在 email 模板 - Check if the email template really exists in SendGrid before sending the email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM