verifiers 0.4.2.dev136__py3-none-any.whl → 0.4.2.dev137__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.
@@ -401,50 +401,81 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
401
401
  # Harbor's dedicated verifier image owns the complete test suite and its
402
402
  # dependencies. Mixing it with packaged tests can retain obsolete helpers.
403
403
  stage = "test -f /tests/test.sh"
404
+ clear = ""
405
+ setup = (
406
+ runtime.with_user("root")
407
+ if runtime.backend.SUPPORTS_USER_SWITCHING
408
+ else runtime
409
+ )
404
410
  if self.data.verifier is None or self.data.verifier_image is None:
405
- await runtime.write(
406
- "/tmp/tests.tgz", make_tar(Path(self.data.task_dir) / "tests")
411
+ owner = ""
412
+ if runtime.backend.SUPPORTS_USER_SWITCHING:
413
+ identity = await runtime.run(["sh", "-c", "id -u; id -g"], {})
414
+ ids = identity.stdout.split()
415
+ if (
416
+ identity.exit_code
417
+ or len(ids) != 2
418
+ or not all(value.isdigit() for value in ids)
419
+ ):
420
+ raise TaskError(
421
+ f"staging tests failed: could not resolve staging user "
422
+ f"(exit {identity.exit_code}): "
423
+ f"{(identity.stderr or identity.stdout).strip()[-500:]}"
424
+ )
425
+ owner = f" && chown {ids[0]}:{ids[1]} /tests && chmod u+rwx /tests"
426
+ # The packaged tests must be all that is in /tests: in a shared box the
427
+ # agent may have left a conftest.py or pytest.ini there, which the tests
428
+ # would load. An existing directory is emptied in place using POSIX sh
429
+ # (preserving any mount point); anything else (a symlink, a file, nothing)
430
+ # is replaced by a fresh directory. Ownership is set to the staging user
431
+ # when switching from root, so a pre-existing /tests (e.g. mode 0700 owned
432
+ # by agent_user) or missing /tests never blocks the non-root unpack.
433
+ # Also clear /tmp/tests.tgz first so an agent-planted file or symlink at
434
+ # that path cannot be written through by `runtime.write`.
435
+ clear = (
436
+ "if [ -d /tests ] && [ ! -L /tests ]; then "
437
+ "for p in /tests/* /tests/.[!.]* /tests/..?*; do "
438
+ 'if [ -e "$p" ] || [ -L "$p" ]; then rm -rf -- "$p" || exit 1; fi; '
439
+ "done; "
440
+ "else rm -f /tests && mkdir /tests; fi"
441
+ f"{owner} && rm -rf /tmp/tests.tgz && "
407
442
  )
408
443
  # The archive holds the hidden tests: left in /tmp, it stays readable by
409
444
  # whatever `test.sh` runs as another user, however /tests is protected.
410
- stage = (
411
- f"{'rm -rf /tests && ' if wipe else ''}"
412
- "mkdir -p /tests && tar -xzf /tmp/tests.tgz -C /tests && "
413
- "rm /tmp/tests.tgz"
414
- )
445
+ stage = "tar -xzf /tmp/tests.tgz -C /tests && rm -f /tmp/tests.tgz"
415
446
  # Verifier subprocesses can use different users; opening their log directory
416
447
  # requires its owner or root, even when it is already writable. A grading box
417
448
  # of its own starts with an empty log directory: anything already there came
418
449
  # from the image or from the agent's restored artifacts, not from this grader.
419
450
  isolated = wipe or self.scoring.mode == "isolated"
420
- setup = (
421
- runtime.with_user("root")
422
- if runtime.backend.SUPPORTS_USER_SWITCHING
423
- else runtime
451
+ prepare = (
452
+ f"{clear}{'rm -rf /logs/verifier && ' if isolated else ''}"
453
+ f"mkdir -p /logs/verifier {ARTIFACTS_DIR} && "
454
+ f"chmod 777 /logs/verifier {ARTIFACTS_DIR}"
424
455
  )
425
- for view, command in (
426
- (
427
- setup,
428
- (
429
- f"{'rm -rf /logs/verifier && ' if isolated else ''}"
430
- f"mkdir -p /logs/verifier {ARTIFACTS_DIR} && "
431
- f"chmod 777 /logs/verifier {ARTIFACTS_DIR}"
432
- ),
433
- ),
434
- (
435
- runtime,
436
- (
437
- "rm -f /logs/verifier/reward.json /logs/verifier/reward.txt && "
438
- f"{stage}"
439
- ),
440
- ),
441
- ):
442
- result = await view.run(["sh", "-c", command], {})
443
- if result.exit_code:
444
- raise TaskError(
445
- f"staging tests failed (exit {result.exit_code}): "
446
- f"{(result.stderr or result.stdout).strip()[-500:]}"
447
- )
456
+ result = await setup.run(["sh", "-c", prepare], {})
457
+ if result.exit_code:
458
+ raise TaskError(
459
+ f"staging tests failed (exit {result.exit_code}): "
460
+ f"{(result.stderr or result.stdout).strip()[-500:]}"
461
+ )
462
+ if clear:
463
+ await runtime.write(
464
+ "/tmp/tests.tgz", make_tar(Path(self.data.task_dir) / "tests")
465
+ )
466
+ result = await runtime.run(
467
+ [
468
+ "sh",
469
+ "-c",
470
+ f"rm -f /logs/verifier/reward.json /logs/verifier/reward.txt && {stage}",
471
+ ],
472
+ {},
473
+ )
474
+ if result.exit_code:
475
+ raise TaskError(
476
+ f"staging tests failed (exit {result.exit_code}): "
477
+ f"{(result.stderr or result.stdout).strip()[-500:]}"
478
+ )
448
479
 
449
480
  @reward(weight=1.0)
450
481
  async def solved(self, runtime: Runtime, trace: Trace) -> float | dict[str, float]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.4.2.dev136
3
+ Version: 0.4.2.dev137
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
@@ -154,7 +154,7 @@ verifiers/v1/runtimes/backends/prime.py,sha256=Z_Sp3Y5yUXWVcmgEEO_1QMeV_HKRyWAaY
154
154
  verifiers/v1/runtimes/backends/subprocess.py,sha256=7JIEetsJWELIf410tkJOcntHT3D_6TPXcsMD3IfhWTw,8595
155
155
  verifiers/v1/tasksets/__init__.py,sha256=2ijE3qIlLoUA02g6iysOwWQylyBBQL1GhSpjv8_bp0w,521
156
156
  verifiers/v1/tasksets/harbor/__init__.py,sha256=FjW4tM3rgGALMK-8p7ux26G4-d4ZFVmaAmO6Fni6e_g,214
157
- verifiers/v1/tasksets/harbor/taskset.py,sha256=d2-_d5KB6g06iYsyI_4hX0zFoptFj9ejRyevrfjXJfs,44279
157
+ verifiers/v1/tasksets/harbor/taskset.py,sha256=rUqhGF7LAYxNqkAE0DBDldSjSBgkFCHeIG7XNQTNIl0,46158
158
158
  verifiers/v1/tasksets/harbor/toolset.py,sha256=l-h1GATE9HLnEjb844CzBAiVLkPmE-XarjBlQ2ec5gM,3969
159
159
  verifiers/v1/tasksets/nemo_gym/__init__.py,sha256=654gAvG3Wd_Z_nh6mypeKn4s_IIQ0Ge6vcZvxTHC2_E,306
160
160
  verifiers/v1/tasksets/nemo_gym/response.py,sha256=EhrsquEP8g0bjzAThGfE6Ypgy86_nVX235NiFYtVDVM,4463
@@ -188,8 +188,8 @@ verifiers/v1/utils/scope.py,sha256=zbs4pj6AVk4jywlAJ3AX0Q0_kzB9dBB02nY-9H4ELdQ,8
188
188
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
189
189
  verifiers/v1/utils/trace_store.py,sha256=7F6xMhYgl3qmylnCU8-ekqswH16fUat1uegeM1OR9QQ,2563
190
190
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
191
- verifiers-0.4.2.dev136.dist-info/METADATA,sha256=clrnyH5MHixC06Z04cYB9cIyuMH_U60DArWfykcBea8,5118
192
- verifiers-0.4.2.dev136.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
193
- verifiers-0.4.2.dev136.dist-info/entry_points.txt,sha256=qdMg7ajiFpDsHf7tuPMRclJXizu1J6LTWawS5YS0B0I,137
194
- verifiers-0.4.2.dev136.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
195
- verifiers-0.4.2.dev136.dist-info/RECORD,,
191
+ verifiers-0.4.2.dev137.dist-info/METADATA,sha256=9bOfmIfbeFx3eI2aX84AVD4I_T65uAUk4WsyGIiLz94,5118
192
+ verifiers-0.4.2.dev137.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
193
+ verifiers-0.4.2.dev137.dist-info/entry_points.txt,sha256=qdMg7ajiFpDsHf7tuPMRclJXizu1J6LTWawS5YS0B0I,137
194
+ verifiers-0.4.2.dev137.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
195
+ verifiers-0.4.2.dev137.dist-info/RECORD,,