verifiers 0.4.2.dev27__py3-none-any.whl → 0.4.2.dev29__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/configs/select.py +29 -1
- verifiers/v1/tasksets/harbor/taskset.py +5 -1
- verifiers/v1/utils/artifacts.py +52 -0
- {verifiers-0.4.2.dev27.dist-info → verifiers-0.4.2.dev29.dist-info}/METADATA +1 -1
- {verifiers-0.4.2.dev27.dist-info → verifiers-0.4.2.dev29.dist-info}/RECORD +8 -8
- {verifiers-0.4.2.dev27.dist-info → verifiers-0.4.2.dev29.dist-info}/WHEEL +0 -0
- {verifiers-0.4.2.dev27.dist-info → verifiers-0.4.2.dev29.dist-info}/entry_points.txt +0 -0
- {verifiers-0.4.2.dev27.dist-info → verifiers-0.4.2.dev29.dist-info}/licenses/LICENSE +0 -0
verifiers/v1/configs/select.py
CHANGED
|
@@ -3,13 +3,24 @@
|
|
|
3
3
|
|
|
4
4
|
import re
|
|
5
5
|
import sys
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
|
-
from pydantic import AliasChoices, Field, field_validator
|
|
8
|
+
from pydantic import AliasChoices, Field, field_validator, model_validator
|
|
8
9
|
from pydantic_config import BaseConfig
|
|
9
10
|
|
|
10
11
|
IDX_RANGE = re.compile(r"(\d*):(\d*)(?::(\d*))?")
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
class TaskMatchFilesConfig(BaseConfig):
|
|
15
|
+
"""Newline-delimited text files with more entries for each `TaskMatchConfig`
|
|
16
|
+
list, one entry per line. Blank lines are skipped."""
|
|
17
|
+
|
|
18
|
+
idx: Path | None = None
|
|
19
|
+
ids: Path | None = None
|
|
20
|
+
keys: Path | None = None
|
|
21
|
+
names: Path | None = None
|
|
22
|
+
|
|
23
|
+
|
|
13
24
|
class TaskMatchConfig(BaseConfig):
|
|
14
25
|
"""Tasks named by position or identity; a task matches when any list names it."""
|
|
15
26
|
|
|
@@ -24,6 +35,10 @@ class TaskMatchConfig(BaseConfig):
|
|
|
24
35
|
"""`Task.key` values, as recorded on each trace (`task.key`)."""
|
|
25
36
|
names: list[str] = Field(default_factory=list)
|
|
26
37
|
"""`TaskData.name` values."""
|
|
38
|
+
files: TaskMatchFilesConfig = TaskMatchFilesConfig()
|
|
39
|
+
"""Files whose lines extend the lists above, for selections too long to write
|
|
40
|
+
inline (`files.ids = "ids.txt"`). Validation reads them into the lists and
|
|
41
|
+
resets `files`."""
|
|
27
42
|
|
|
28
43
|
@field_validator("idx", mode="before")
|
|
29
44
|
@classmethod
|
|
@@ -36,6 +51,19 @@ class TaskMatchConfig(BaseConfig):
|
|
|
36
51
|
items.extend(_parse_idx_item(part) for part in parts)
|
|
37
52
|
return items
|
|
38
53
|
|
|
54
|
+
@model_validator(mode="after")
|
|
55
|
+
def _read_files(self):
|
|
56
|
+
for field, path in self.files:
|
|
57
|
+
if path is None:
|
|
58
|
+
continue
|
|
59
|
+
lines = [line.strip() for line in path.read_text().splitlines()]
|
|
60
|
+
entries = [line for line in lines if line]
|
|
61
|
+
if field == "idx":
|
|
62
|
+
entries = [_parse_idx_item(entry) for entry in entries]
|
|
63
|
+
getattr(self, field).extend(entries)
|
|
64
|
+
self.files = TaskMatchFilesConfig()
|
|
65
|
+
return self
|
|
66
|
+
|
|
39
67
|
@property
|
|
40
68
|
def empty(self) -> bool:
|
|
41
69
|
return not (self.idx or self.ids or self.keys or self.names)
|
|
@@ -410,7 +410,10 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
|
|
|
410
410
|
"mkdir -p /tests && tar -xzf /tmp/tests.tgz -C /tests"
|
|
411
411
|
)
|
|
412
412
|
# Verifier subprocesses can use different users; opening their log directory
|
|
413
|
-
# requires its owner or root, even when it is already writable.
|
|
413
|
+
# requires its owner or root, even when it is already writable. A grading box
|
|
414
|
+
# of its own starts with an empty log directory: anything already there came
|
|
415
|
+
# from the image or from the agent's restored artifacts, not from this grader.
|
|
416
|
+
isolated = wipe or self.scoring.mode == "isolated"
|
|
414
417
|
setup = (
|
|
415
418
|
runtime.with_user("root")
|
|
416
419
|
if runtime.backend.SUPPORTS_USER_SWITCHING
|
|
@@ -420,6 +423,7 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
|
|
|
420
423
|
(
|
|
421
424
|
setup,
|
|
422
425
|
(
|
|
426
|
+
f"{'rm -rf /logs/verifier && ' if isolated else ''}"
|
|
423
427
|
f"mkdir -p /logs/verifier {ARTIFACTS_DIR} && "
|
|
424
428
|
f"chmod 777 /logs/verifier {ARTIFACTS_DIR}"
|
|
425
429
|
),
|
verifiers/v1/utils/artifacts.py
CHANGED
|
@@ -341,6 +341,10 @@ async def restore(runtime: Runtime, collected: dict[str, bytes | None]) -> None:
|
|
|
341
341
|
)
|
|
342
342
|
for root, archive in collected.items():
|
|
343
343
|
_validate_restore(root, archive)
|
|
344
|
+
collected = {
|
|
345
|
+
root: None if archive is None else _rebuild(archive)
|
|
346
|
+
for root, archive in collected.items()
|
|
347
|
+
}
|
|
344
348
|
# Clear every root up front, not per entry: a later nested root would otherwise
|
|
345
349
|
# delete content an earlier one just restored. Clearing also drops any file or
|
|
346
350
|
# symlink the image left at the target.
|
|
@@ -425,6 +429,45 @@ def _drop_special_files(archive: bytes) -> tuple[bytes, list[str]]:
|
|
|
425
429
|
return out.getvalue(), dropped
|
|
426
430
|
|
|
427
431
|
|
|
432
|
+
def _rebuild(archive: bytes) -> bytes:
|
|
433
|
+
"""Write a fresh archive holding exactly the members Python's tarfile reads.
|
|
434
|
+
|
|
435
|
+
Validation reads archives with Python's tarfile, but the grading box extracts
|
|
436
|
+
them with its own tar. An agent controls the archive bytes, and two tar parsers
|
|
437
|
+
can disagree about the same bytes, so the box only ever extracts an archive
|
|
438
|
+
written here from the members validation saw. Owners and permission bits are
|
|
439
|
+
kept (tasks rely on ownership, e.g. git's safe.directory check); setuid,
|
|
440
|
+
setgid and sticky bits are not.
|
|
441
|
+
"""
|
|
442
|
+
out = io.BytesIO()
|
|
443
|
+
with (
|
|
444
|
+
tarfile.open(fileobj=io.BytesIO(archive), mode="r:") as source,
|
|
445
|
+
tarfile.open(fileobj=out, mode="w:", format=tarfile.PAX_FORMAT) as target,
|
|
446
|
+
):
|
|
447
|
+
for member in source:
|
|
448
|
+
info = tarfile.TarInfo(member.name)
|
|
449
|
+
info.mode = member.mode & 0o777
|
|
450
|
+
info.uid, info.gid = member.uid, member.gid
|
|
451
|
+
info.uname, info.gname = member.uname, member.gname
|
|
452
|
+
info.mtime = member.mtime
|
|
453
|
+
content = None
|
|
454
|
+
if member.isfile():
|
|
455
|
+
info.type = tarfile.REGTYPE
|
|
456
|
+
info.size = member.size
|
|
457
|
+
content = source.extractfile(member)
|
|
458
|
+
elif member.isdir():
|
|
459
|
+
info.type = tarfile.DIRTYPE
|
|
460
|
+
elif member.issym() or member.islnk():
|
|
461
|
+
info.type = tarfile.SYMTYPE if member.issym() else tarfile.LNKTYPE
|
|
462
|
+
info.linkname = member.linkname
|
|
463
|
+
else:
|
|
464
|
+
raise RuntimeError(
|
|
465
|
+
f"artifact member {member.name!r} is a link or special file"
|
|
466
|
+
)
|
|
467
|
+
target.addfile(info, content)
|
|
468
|
+
return out.getvalue()
|
|
469
|
+
|
|
470
|
+
|
|
428
471
|
def _validate_restore(root: str, archive: bytes | None) -> None:
|
|
429
472
|
"""Reject archive content that could restore outside its declared root."""
|
|
430
473
|
root_path = PurePosixPath(root)
|
|
@@ -482,6 +525,15 @@ def _validate_restore(root: str, archive: bytes | None) -> None:
|
|
|
482
525
|
raise RuntimeError(
|
|
483
526
|
f"artifact member {member.name!r} is a link or special file"
|
|
484
527
|
)
|
|
528
|
+
if member.issparse():
|
|
529
|
+
# A sparse member declares its full size in a few header bytes,
|
|
530
|
+
# and rebuilding the archive on the host would write every hole
|
|
531
|
+
# out as zeros. GNU tar only writes these with --sparse; bsdtar
|
|
532
|
+
# writes them for any file with holes.
|
|
533
|
+
raise RuntimeError(
|
|
534
|
+
f"artifact member {member.name!r} is a sparse file, which "
|
|
535
|
+
"cannot be restored"
|
|
536
|
+
)
|
|
485
537
|
if member.isfile():
|
|
486
538
|
regular_files.add(member_path)
|
|
487
539
|
# Check after reading the whole archive, so a later symlink cannot
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: verifiers
|
|
3
|
-
Version: 0.4.2.
|
|
3
|
+
Version: 0.4.2.dev29
|
|
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
|
|
@@ -44,7 +44,7 @@ verifiers/v1/configs/retries.py,sha256=GIrwS0lnMKnlQ_Wj1Z2J6NlEYK4jX5weZxYmQmLcp
|
|
|
44
44
|
verifiers/v1/configs/runtime.py,sha256=7To2aecnYuv_ThVt5OIlKUiocldmt4O0hZzkSwuJsBI,11773
|
|
45
45
|
verifiers/v1/configs/sampling.py,sha256=bd6lietww4htrNYmUEqwK5yfKMhUT3nEjHoCg5xl_ys,1174
|
|
46
46
|
verifiers/v1/configs/scoring.py,sha256=8t5NrQU9b8R9dGdcG-aQm_U1m3TgeMIbw_XUN4esoF0,3115
|
|
47
|
-
verifiers/v1/configs/select.py,sha256=
|
|
47
|
+
verifiers/v1/configs/select.py,sha256=bLMJAb7i23IxU6BZMIS0Q_K5JYLlcwL8zi87REhrccc,5827
|
|
48
48
|
verifiers/v1/configs/task.py,sha256=3CB9pumHdxAHlxLKuLEiCfQPW37tNqy_HC6DgG2GKj4,2958
|
|
49
49
|
verifiers/v1/configs/taskset.py,sha256=rQow8AJL34n-ZVQ_4GPjPIW5fzBL5QU_RTjJO9tlmwU,945
|
|
50
50
|
verifiers/v1/configs/cli/__init__.py,sha256=YMDUPdbRlDJ77dhj3QqzmyRhqNgUvuQdpj_bdBqzZPM,78
|
|
@@ -159,7 +159,7 @@ verifiers/v1/runtimes/backends/prime.py,sha256=qTTIrmMbEluKIwHQ4kwRnKXn6RIT-P3mZ
|
|
|
159
159
|
verifiers/v1/runtimes/backends/subprocess.py,sha256=naOWJGmcaOlu2ZdRbUwhJicJdxASDRAUhDT0jzDff3w,8591
|
|
160
160
|
verifiers/v1/tasksets/__init__.py,sha256=2ijE3qIlLoUA02g6iysOwWQylyBBQL1GhSpjv8_bp0w,521
|
|
161
161
|
verifiers/v1/tasksets/harbor/__init__.py,sha256=FjW4tM3rgGALMK-8p7ux26G4-d4ZFVmaAmO6Fni6e_g,214
|
|
162
|
-
verifiers/v1/tasksets/harbor/taskset.py,sha256=
|
|
162
|
+
verifiers/v1/tasksets/harbor/taskset.py,sha256=g9uLfSclESw5XV56T9h0TXD9dm9W2FrkpVgegbokctU,43686
|
|
163
163
|
verifiers/v1/tasksets/harbor/toolset.py,sha256=_7HXu-uuvqzhmJ1EX6c3KWLg0g0eRrLjCq1kBsZhIwo,3159
|
|
164
164
|
verifiers/v1/tasksets/nemo_gym/__init__.py,sha256=654gAvG3Wd_Z_nh6mypeKn4s_IIQ0Ge6vcZvxTHC2_E,306
|
|
165
165
|
verifiers/v1/tasksets/nemo_gym/response.py,sha256=EhrsquEP8g0bjzAThGfE6Ypgy86_nVX235NiFYtVDVM,4463
|
|
@@ -172,7 +172,7 @@ verifiers/v1/tasksets/textarena/__init__.py,sha256=Os2OlBY_pSH0B1DP32RitumgSLpq2
|
|
|
172
172
|
verifiers/v1/tasksets/textarena/taskset.py,sha256=zGslerxmH2ZT7FJdP-72R6a9p71kr2pNS3r5_xnq1lQ,4406
|
|
173
173
|
verifiers/v1/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
174
174
|
verifiers/v1/utils/aio.py,sha256=0yNFOqB2oO6Qktc6NI_ZSAGuo1aHsIK_wuT1BtmoZ3I,1532
|
|
175
|
-
verifiers/v1/utils/artifacts.py,sha256=
|
|
175
|
+
verifiers/v1/utils/artifacts.py,sha256=QWquQli7wfPxPOaKvP4Nn2anQyozrh-DOJwLpZhK_ak,25222
|
|
176
176
|
verifiers/v1/utils/compile.py,sha256=J5PzohCTCj9UQ1d6rmQB-pTJKLYa_f6-0YMZ9y3yWoA,5308
|
|
177
177
|
verifiers/v1/utils/decorators.py,sha256=LbHW0bPkFy-l_TNp48HDDB_PZVr7wvJuVfuo3Qctcbo,5608
|
|
178
178
|
verifiers/v1/utils/env.py,sha256=tMqfwFNRcJPijzrjkbE2VYvBH8eONRtYCWVkXHKpGZQ,1023
|
|
@@ -193,8 +193,8 @@ verifiers/v1/utils/scope.py,sha256=zbs4pj6AVk4jywlAJ3AX0Q0_kzB9dBB02nY-9H4ELdQ,8
|
|
|
193
193
|
verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
|
|
194
194
|
verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
|
|
195
195
|
verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
|
|
196
|
-
verifiers-0.4.2.
|
|
197
|
-
verifiers-0.4.2.
|
|
198
|
-
verifiers-0.4.2.
|
|
199
|
-
verifiers-0.4.2.
|
|
200
|
-
verifiers-0.4.2.
|
|
196
|
+
verifiers-0.4.2.dev29.dist-info/METADATA,sha256=vrJ8ZEQ7TSZnoOZt4GXFatKpwhMc26J96t4y3zvgRNE,5142
|
|
197
|
+
verifiers-0.4.2.dev29.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
198
|
+
verifiers-0.4.2.dev29.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
|
|
199
|
+
verifiers-0.4.2.dev29.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
|
|
200
|
+
verifiers-0.4.2.dev29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|