diff --git a/tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py b/tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py index d5170d5b24..cf575d62be 100644 --- a/tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py +++ b/tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py @@ -92,7 +92,10 @@ def create_batch_oai_sdk(filepath: str, custom_llm_provider: str) -> str: def await_batch_completion(batch_id: str, custom_llm_provider: str): - while True: + max_tries = 3 + tries = 0 + + while tries < max_tries: batch = client.batches.retrieve( batch_id, extra_body={"custom_llm_provider": custom_llm_provider} ) @@ -100,9 +103,14 @@ def await_batch_completion(batch_id: str, custom_llm_provider: str): print(f"Batch {batch_id} completed.") return - print("waiting for batch to complete...") + tries += 1 + print(f"waiting for batch to complete... (attempt {tries}/{max_tries})") time.sleep(10) + print( + f"Reached maximum number of attempts ({max_tries}). Batch may still be processing." + ) + def write_content_to_file( batch_id: str, output_path: str, custom_llm_provider: str