verifiers 0.2.2.dev21__py3-none-any.whl → 0.2.2.dev23__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
verifiers/v1/push.py CHANGED
@@ -6,6 +6,7 @@ contract as `prime eval push`, done inline at the end of a run. Auth + base URL
6
6
  come from `$PRIME_API_KEY` / `~/.prime/config.json`.
7
7
  """
8
8
 
9
+ import json
9
10
  import logging
10
11
  import os
11
12
  from dataclasses import dataclass
@@ -22,6 +23,8 @@ logger = logging.getLogger(__name__)
22
23
 
23
24
  DEFAULT_API_URL = "https://api.primeintellect.ai"
24
25
  DEFAULT_FRONTEND_URL = "https://app.primeintellect.ai"
26
+ # Repeated /samples posts append; match the Prime Evals client's request ceiling.
27
+ _MAX_SAMPLES_PAYLOAD_BYTES = 25 * 1024 * 1024
25
28
 
26
29
 
27
30
  @dataclass
@@ -200,6 +203,36 @@ def push_traces(
200
203
  # The run is done and its results saved; a network blip here must not crash it
201
204
  # — log and skip the upload instead.
202
205
  try:
206
+ batches: list[list[dict[str, Any]]] = []
207
+ batch: list[dict[str, Any]] = []
208
+ payload_bytes = len(b'{"samples":[]}')
209
+ for i, sample in enumerate(samples):
210
+ sample_bytes = len(
211
+ json.dumps(
212
+ sample,
213
+ ensure_ascii=False,
214
+ separators=(",", ":"),
215
+ allow_nan=False,
216
+ ).encode("utf-8")
217
+ )
218
+ sample_payload_bytes = len(b'{"samples":[]}') + sample_bytes
219
+ if sample_payload_bytes > _MAX_SAMPLES_PAYLOAD_BYTES:
220
+ raise ValueError(
221
+ f"sample {i} is too large to upload "
222
+ f"({sample_payload_bytes} > "
223
+ f"{_MAX_SAMPLES_PAYLOAD_BYTES} bytes)"
224
+ )
225
+ next_payload_bytes = payload_bytes + (1 if batch else 0) + sample_bytes
226
+ if batch and next_payload_bytes > _MAX_SAMPLES_PAYLOAD_BYTES:
227
+ batches.append(batch)
228
+ batch = []
229
+ payload_bytes = len(b'{"samples":[]}')
230
+ next_payload_bytes = payload_bytes + sample_bytes
231
+ batch.append(sample)
232
+ payload_bytes = next_payload_bytes
233
+ if batch or not samples:
234
+ batches.append(batch)
235
+
203
236
  with httpx.Client(headers=headers, timeout=300.0) as client:
204
237
 
205
238
  def post(path: str, body: dict) -> dict:
@@ -224,7 +257,18 @@ def push_traces(
224
257
  **team,
225
258
  },
226
259
  )["evaluation_id"]
227
- post(f"/evaluations/{eval_id}/samples", {"samples": samples})
260
+ for batch in batches:
261
+ body = json.dumps(
262
+ {"samples": batch},
263
+ ensure_ascii=False,
264
+ separators=(",", ":"),
265
+ allow_nan=False,
266
+ ).encode("utf-8")
267
+ resp = client.post(
268
+ f"{api}/evaluations/{eval_id}/samples",
269
+ content=body,
270
+ )
271
+ resp.raise_for_status()
228
272
  post(f"/evaluations/{eval_id}/finalize", {"metrics": metrics})
229
273
  except Exception as e:
230
274
  logger.warning("--push: upload failed (%s: %s); skipping", type(e).__name__, e)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: verifiers
3
- Version: 0.2.2.dev21
3
+ Version: 0.2.2.dev23
4
4
  Summary: Verifiers: Environments for LLM Reinforcement Learning
5
5
  Project-URL: Homepage, https://github.com/primeintellect-ai/verifiers
6
6
  Project-URL: Documentation, https://github.com/primeintellect-ai/verifiers
@@ -178,7 +178,7 @@ verifiers/v1/harness.py,sha256=2DVutCeW5vNgL3TFuigQlQXvbD1oTTRpjhIIiu4kq00,12076
178
178
  verifiers/v1/judge.py,sha256=u15e7YXPUKi-DWhqTrwsRy0M7UTj7O0066Rwm-RAXmU,11668
179
179
  verifiers/v1/legacy.py,sha256=b53EDDOImu8rSaZR_ZE7jNaQTJ6aIw5T8hxlXU4fTh0,22280
180
180
  verifiers/v1/loaders.py,sha256=ISI0UKk8UXUOJke8n2M3F0EpPmqqnTgey0QDq9Ryo8I,9808
181
- verifiers/v1/push.py,sha256=_wRGO6UTQURSBFyPQzXSdkZGQEGZh6PyVzKNJgkyJVM,9329
181
+ verifiers/v1/push.py,sha256=ltEyEnfYAf5XTOxpYx8sNVQ4NRYXcQ6yM_GCtDdWOvg,11134
182
182
  verifiers/v1/retries.py,sha256=5-LQZ2A7Tr1dpTtoJ-bX0_BrzecHm9Drf3EfQUIjVAw,6010
183
183
  verifiers/v1/rollout.py,sha256=G2eewd78SeY4CotprjXdXUTCEX4Z3-9bXJ3B1orr7N8,20217
184
184
  verifiers/v1/scoring.py,sha256=I_mtqhTZ195hj2-CB5jzr3BY5GFKgNEvTf331f7Is4k,5740
@@ -319,8 +319,8 @@ verifiers/v1/utils/logging.py,sha256=OcMHA6NsYux3oIzjPuI95rDWmFBHNcHDjZeNIhXTX-Y
319
319
  verifiers/v1/utils/memory.py,sha256=ZkIvGk6uITAH5sKon65LifKPbvZr8mJ__PVc23FZpOQ,1835
320
320
  verifiers/v1/utils/sampling.py,sha256=JczGzBn6s3wsIrSY2Hy3hE8m6NreNgsNzhSjDikQqX0,1037
321
321
  verifiers/v1/utils/version.py,sha256=75ZtI2NHBmlb52KpcKLUpiSXp8q4bASr7uKeXoCKlT8,1582
322
- verifiers-0.2.2.dev21.dist-info/METADATA,sha256=QgW8FGmPC7aHIc_rPSK_iqVsONvmUc-F7tl_WN7f0OI,4540
323
- verifiers-0.2.2.dev21.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
324
- verifiers-0.2.2.dev21.dist-info/entry_points.txt,sha256=dF82JUYEFslR1AOW8LZfuBWeZeQoyX4wCRrduklg8-I,551
325
- verifiers-0.2.2.dev21.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
326
- verifiers-0.2.2.dev21.dist-info/RECORD,,
322
+ verifiers-0.2.2.dev23.dist-info/METADATA,sha256=f99cAbMaLDFAktFRuJ2dUQHvn8sOzlfN2IeZ1CK9D_w,4540
323
+ verifiers-0.2.2.dev23.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
324
+ verifiers-0.2.2.dev23.dist-info/entry_points.txt,sha256=dF82JUYEFslR1AOW8LZfuBWeZeQoyX4wCRrduklg8-I,551
325
+ verifiers-0.2.2.dev23.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
326
+ verifiers-0.2.2.dev23.dist-info/RECORD,,