feat 新增 process lookbooks 接口

fix
This commit is contained in:
zhouchengrong
2024-10-21 11:01:28 +08:00
parent 3417bcb2ab
commit e88ba6994a
11 changed files with 371 additions and 6 deletions

View File

@@ -0,0 +1,31 @@
import time
def wait_for_job_completion(client, batch_job_id, timeout=6000, interval=10):
"""
等待批处理作业完成。
参数:
- client: 批处理作业客户端对象
- batch_job_id: 批处理作业的ID
- timeout: 最大等待时间(秒)
- interval: 检查状态的间隔时间(秒)
返回:
- True 如果作业完成False 如果超时
"""
start_time = time.time()
while time.time() - start_time < timeout:
batch_job = client.batches.retrieve(batch_job_id)
if batch_job.status == 'completed':
print("Batch job completed successfully.")
return True
elif batch_job.status == 'failed':
print("Batch job failed.")
return False
else:
print(f"Current status: {batch_job.status}. Waiting for completion...")
time.sleep(interval)
print("Timeout reached, job did not complete in time.")
return False