Skip to content

Commit d21a164

Browse files
committed
Fixing async stuff
1 parent 3ca305d commit d21a164

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

olmocr/train/compare_vllm_checkpoint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def image_to_base64_data_url(image):
6262
return f"data:image/png;base64,{img_str}"
6363

6464

65-
def load_pdf_prompts(num_samples: int = 100, seed: int = 42, max_length: int = 2048) -> List[Dict[str, str]]:
65+
async def load_pdf_prompts(num_samples: int = 100, seed: int = 42, max_length: int = 2048) -> List[Dict[str, str]]:
6666
"""Load prompts and images from olmOCR-mix-0225-benchmarkset dataset with fixed random seed."""
6767
print(f"Loading olmOCR-mix-0225-benchmarkset dataset with {num_samples} samples and seed {seed}")
6868

@@ -101,12 +101,12 @@ def load_pdf_prompts(num_samples: int = 100, seed: int = 42, max_length: int = 2
101101
for pdf_path in sampled_pdfs:
102102
try:
103103
# Build page query for page 1 of each PDF
104-
query = asyncio.run(build_page_query(
104+
query = await build_page_query(
105105
local_pdf_path=pdf_path,
106106
page=1,
107107
target_longest_image_dim=1280,
108108
image_rotation=0
109-
))
109+
)
110110
queries.append(query)
111111
except Exception as e:
112112
print(f"Error processing {os.path.basename(pdf_path)}: {e}")
@@ -316,7 +316,7 @@ async def async_main():
316316
model_path = await download_model(args.model)
317317

318318
# Load prompts and images
319-
samples = load_pdf_prompts(num_samples=args.num_prompts, seed=args.seed)
319+
samples = await load_pdf_prompts(num_samples=args.num_prompts, seed=args.seed)
320320

321321
# Create vLLM engine
322322
print("\n=== Creating vLLM Engine ===")

0 commit comments

Comments
 (0)