MCPcopy Create free account
hub / github.com/CodeGoat24/UniGenBench / evaluate_batch

Function evaluate_batch

eval/src/vllm_request.py:168–269  ·  view source on GitHub ↗
(
    batch_data,
    api_url,
    image_root=None,
    output_file="./results.json",
    error_file=None,
    max_workers=None,
    max_retries=10,
    timeout_base=160,
    backoff_base=2,
    backoff_cap=10,
    flush_every=20,
    log_stats=None,
)

Source from the content-addressed store, hash-verified

166
167
168def evaluate_batch(
169 batch_data,
170 api_url,
171 image_root=None,
172 output_file="./results.json",
173 error_file=None,
174 max_workers=None,
175 max_retries=10,
176 timeout_base=160,
177 backoff_base=2,
178 backoff_cap=10,
179 flush_every=20,
180 log_stats=None,
181):
182 success_count = 0
183 total_result = []
184 durations = []
185 output_buffer = []
186 error_buffer = []
187
188 if max_workers is None:
189 max_workers = int(os.getenv("VLLM_MAX_WORKERS", "16"))
190 max_workers = max(1, min(max_workers, len(batch_data)))
191
192 client = VLMessageClient(
193 api_url,
194 timeout_base=timeout_base,
195 max_retries=max_retries,
196 backoff_base=backoff_base,
197 backoff_cap=backoff_cap,
198 pool_maxsize=max_workers,
199 )
200
201 if log_stats is None:
202 log_stats = os.getenv("VLLM_LOG_STATS", "0") == "1"
203
204 def flush_buffer(buffer, path):
205 if not buffer or not path:
206 return
207 with open(path, "a", encoding="utf-8") as f:
208 for row in buffer:
209 f.write(json.dumps(row, ensure_ascii=False) + "\n")
210 buffer.clear()
211
212 with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
213 futures = []
214 index = 0
215 for item in batch_data:
216 if "idx" not in item:
217 item["idx"] = str(index)
218 index += 1
219 futures.append(
220 executor.submit(
221 client.process_item,
222 item=item,
223 image_root=image_root,
224 )
225 )

Callers 2

call_evaluation_vllmFunction · 0.90
mainFunction · 0.85

Calls 2

VLMessageClientClass · 0.85
flush_bufferFunction · 0.85

Tested by

no test coverage detected