Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test fix await_batch_completion

Ishaan Jaff3d87bf9fe68f
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 d5170d5b242..cf575d62bed 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