verifiers 0.4.2.dev6__py3-none-any.whl → 0.4.2.dev7__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/runtimes/native_compose.py +69 -9
- verifiers/v1/tasksets/harbor/taskset.py +28 -9
- {verifiers-0.4.2.dev6.dist-info → verifiers-0.4.2.dev7.dist-info}/METADATA +1 -1
- {verifiers-0.4.2.dev6.dist-info → verifiers-0.4.2.dev7.dist-info}/RECORD +7 -7
- {verifiers-0.4.2.dev6.dist-info → verifiers-0.4.2.dev7.dist-info}/WHEEL +0 -0
- {verifiers-0.4.2.dev6.dist-info → verifiers-0.4.2.dev7.dist-info}/entry_points.txt +0 -0
- {verifiers-0.4.2.dev6.dist-info → verifiers-0.4.2.dev7.dist-info}/licenses/LICENSE +0 -0
|
@@ -17,12 +17,13 @@ from pathlib import Path, PurePosixPath
|
|
|
17
17
|
|
|
18
18
|
import httpx
|
|
19
19
|
from prime_sandboxes import AsyncImageClient
|
|
20
|
-
from prime_sandboxes.models import BuildImageRequest
|
|
20
|
+
from prime_sandboxes.models import BuildImageRequest, LocalhostForward
|
|
21
21
|
from pydantic import ByteSize, TypeAdapter
|
|
22
22
|
|
|
23
23
|
from verifiers.v1.errors import SandboxError
|
|
24
24
|
from verifiers.v1.runtimes import PrimeConfig
|
|
25
25
|
from verifiers.v1.runtimes.backends.docker import cli
|
|
26
|
+
from verifiers.v1.runtimes.backends.prime import leased_client
|
|
26
27
|
from verifiers.v1.runtimes.base import RuntimeBackend, RuntimeProcess
|
|
27
28
|
from verifiers.v1.runtimes.compose import ComposeSpec, compose_project
|
|
28
29
|
from verifiers.v1.runtimes.private_network import lan_host
|
|
@@ -137,9 +138,10 @@ class NativeService:
|
|
|
137
138
|
internal: bool = False
|
|
138
139
|
mounts: list[NativeMount] = field(default_factory=list)
|
|
139
140
|
image_env: dict[str, str] = field(default_factory=dict)
|
|
141
|
+
localhost_forwards: dict[int, str] = field(default_factory=dict)
|
|
140
142
|
|
|
141
143
|
|
|
142
|
-
def validate_native(project) ->
|
|
144
|
+
def validate_native(project) -> dict[str, str]:
|
|
143
145
|
config = project.config
|
|
144
146
|
# Compose keeps top-level `x-*` extension blocks (YAML anchors); they configure nothing.
|
|
145
147
|
if {key for key in config if not key.startswith("x-")} - {
|
|
@@ -165,6 +167,23 @@ def validate_native(project) -> None:
|
|
|
165
167
|
mounts: dict[str, set[tuple[str, str]]] = {}
|
|
166
168
|
binds: list[tuple[str, str, Path, bool]] = []
|
|
167
169
|
task = (project.directory / "task").resolve()
|
|
170
|
+
services = config["services"]
|
|
171
|
+
network_owners = {}
|
|
172
|
+
for name, service in services.items():
|
|
173
|
+
owner, seen = name, {name}
|
|
174
|
+
while (mode := services[owner].get("network_mode", "")).startswith("service:"):
|
|
175
|
+
owner = mode.removeprefix("service:")
|
|
176
|
+
if owner not in services or owner in seen:
|
|
177
|
+
raise SandboxError(
|
|
178
|
+
f"Native Compose service {name!r} has an invalid or cyclic network_mode"
|
|
179
|
+
)
|
|
180
|
+
seen.add(owner)
|
|
181
|
+
network_owners[name] = owner
|
|
182
|
+
if owner != name:
|
|
183
|
+
# Separate VMs join the owner's LANs; declared ports are forwarded below.
|
|
184
|
+
service["networks"] = {
|
|
185
|
+
network: {} for network in services[owner].get("networks", {})
|
|
186
|
+
}
|
|
168
187
|
for name, service in config["services"].items():
|
|
169
188
|
unsupported = set(service) - _SERVICE_FIELDS
|
|
170
189
|
if unsupported:
|
|
@@ -272,7 +291,7 @@ def validate_native(project) -> None:
|
|
|
272
291
|
mounts.setdefault(volume["source"], set()).add((name, volume["target"]))
|
|
273
292
|
# Docker's default bridge network: no project network, so no service names.
|
|
274
293
|
mode = service.get("network_mode")
|
|
275
|
-
if mode not in {None, "bridge", "default"}:
|
|
294
|
+
if mode not in {None, "bridge", "default"} and network_owners[name] == name:
|
|
276
295
|
raise SandboxError(
|
|
277
296
|
f"Native Compose service {name!r} does not support network_mode {mode!r}"
|
|
278
297
|
)
|
|
@@ -333,6 +352,7 @@ def validate_native(project) -> None:
|
|
|
333
352
|
f"Native Compose binds overlapping task files writable at "
|
|
334
353
|
f"{name}:{target} and {other}:{other_target}"
|
|
335
354
|
)
|
|
355
|
+
return network_owners
|
|
336
356
|
|
|
337
357
|
|
|
338
358
|
async def prepare_native(config: PrimeConfig, spec: ComposeSpec, env: dict[str, str]):
|
|
@@ -340,7 +360,7 @@ async def prepare_native(config: PrimeConfig, spec: ComposeSpec, env: dict[str,
|
|
|
340
360
|
if spec.workspace != "main" or config.checkpoint or config.gpu:
|
|
341
361
|
raise SandboxError("Native Compose requires a CPU image workspace named 'main'")
|
|
342
362
|
async with compose_project(config, spec, env) as project:
|
|
343
|
-
validate_native(project)
|
|
363
|
+
network_owners = validate_native(project)
|
|
344
364
|
prepared = {
|
|
345
365
|
**project.config,
|
|
346
366
|
"networks": {},
|
|
@@ -412,6 +432,7 @@ async def prepare_native(config: PrimeConfig, spec: ComposeSpec, env: dict[str,
|
|
|
412
432
|
for image in images
|
|
413
433
|
}
|
|
414
434
|
image_sizes = {image["Id"]: image["Size"] for image in images}
|
|
435
|
+
image_filesystems = {image["Id"]: image["RootFS"] for image in images}
|
|
415
436
|
services, bound = {}, 0
|
|
416
437
|
for name in ids:
|
|
417
438
|
item = inspected[name]
|
|
@@ -483,6 +504,30 @@ async def prepare_native(config: PrimeConfig, spec: ComposeSpec, env: dict[str,
|
|
|
483
504
|
image_env=image_envs[item["Image"]],
|
|
484
505
|
)
|
|
485
506
|
bound += sum(len(mount.archive or b"") for mount in services[name].mounts)
|
|
507
|
+
for owner in dict.fromkeys(network_owners.values()):
|
|
508
|
+
members = [name for name in services if network_owners[name] == owner]
|
|
509
|
+
if len(members) == 1:
|
|
510
|
+
continue
|
|
511
|
+
ports = {}
|
|
512
|
+
for name in members:
|
|
513
|
+
for exposed in inspected[name]["Config"].get("ExposedPorts") or {}:
|
|
514
|
+
port, protocol = exposed.split("/")
|
|
515
|
+
if protocol != "tcp" or int(port) in ports:
|
|
516
|
+
raise SandboxError(
|
|
517
|
+
"Native Compose localhost groups require unique exposed TCP ports"
|
|
518
|
+
)
|
|
519
|
+
ports[int(port)] = name
|
|
520
|
+
if not ports:
|
|
521
|
+
raise SandboxError(
|
|
522
|
+
"Native Compose network_mode service requires ports declared by expose or Dockerfile EXPOSE"
|
|
523
|
+
)
|
|
524
|
+
for name in members:
|
|
525
|
+
forwards = {port: peer for port, peer in ports.items() if peer != name}
|
|
526
|
+
if len(forwards) > 64:
|
|
527
|
+
raise SandboxError(
|
|
528
|
+
f"Native Compose service {name!r} exceeds 64 localhost forwards"
|
|
529
|
+
)
|
|
530
|
+
services[name].localhost_forwards = forwards
|
|
486
531
|
for name, service in services.items():
|
|
487
532
|
for dependency, options in service.definition.get("depends_on", {}).items():
|
|
488
533
|
if options["condition"] == "service_healthy" and (
|
|
@@ -496,10 +541,14 @@ async def prepare_native(config: PrimeConfig, spec: ComposeSpec, env: dict[str,
|
|
|
496
541
|
try:
|
|
497
542
|
images = {}
|
|
498
543
|
for name, service in services.items():
|
|
499
|
-
|
|
544
|
+
# Compose's per-project labels change image IDs without changing files.
|
|
545
|
+
identity = json.dumps(
|
|
546
|
+
[image_filesystems[service.config.image], service.config.workdir],
|
|
547
|
+
sort_keys=True,
|
|
548
|
+
)
|
|
500
549
|
if identity not in images:
|
|
501
550
|
images[identity] = await _import_image(
|
|
502
|
-
client, project, ids[name],
|
|
551
|
+
client, project, ids[name], identity
|
|
503
552
|
)
|
|
504
553
|
service.config = service.config.model_copy(
|
|
505
554
|
update={"image": images[identity]}
|
|
@@ -599,9 +648,8 @@ async def _mount(runtime, name: str, mounts: list[NativeMount]) -> None:
|
|
|
599
648
|
)
|
|
600
649
|
|
|
601
650
|
|
|
602
|
-
async def _import_image(client, project, container: str,
|
|
603
|
-
"""Cache a private VM image by
|
|
604
|
-
identity = f"{config.image}\n{config.workdir}"
|
|
651
|
+
async def _import_image(client, project, container: str, identity: str) -> str:
|
|
652
|
+
"""Cache a private VM image by its filesystem layers and container workdir."""
|
|
605
653
|
name = "vf-compose-" + hashlib.sha256(identity.encode()).hexdigest()
|
|
606
654
|
locks = CACHE_DIR / "compose-images"
|
|
607
655
|
locks.mkdir(parents=True, exist_ok=True)
|
|
@@ -701,6 +749,18 @@ class NativeProcesses:
|
|
|
701
749
|
for name, backend in deployment.target_backends.items():
|
|
702
750
|
service = self.services[name]
|
|
703
751
|
runtime = backend.bind().with_user(None).with_env({})
|
|
752
|
+
if service.localhost_forwards:
|
|
753
|
+
async with leased_client() as client:
|
|
754
|
+
await client.set_localhost_forwards(
|
|
755
|
+
backend.info.id,
|
|
756
|
+
[
|
|
757
|
+
LocalhostForward(
|
|
758
|
+
port=port,
|
|
759
|
+
sandbox_id=deployment.target_backends[peer].info.id,
|
|
760
|
+
)
|
|
761
|
+
for port, peer in service.localhost_forwards.items()
|
|
762
|
+
],
|
|
763
|
+
)
|
|
704
764
|
peers = {
|
|
705
765
|
peer: shared
|
|
706
766
|
for peer, other in self.services.items()
|
|
@@ -409,16 +409,35 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
|
|
|
409
409
|
f"{'rm -rf /tests && ' if wipe else ''}"
|
|
410
410
|
"mkdir -p /tests && tar -xzf /tmp/tests.tgz -C /tests"
|
|
411
411
|
)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
# Verifier subprocesses can use different users; opening their log directory
|
|
413
|
+
# requires its owner or root, even when it is already writable.
|
|
414
|
+
setup = (
|
|
415
|
+
runtime.with_user("root")
|
|
416
|
+
if runtime.backend.SUPPORTS_USER_SWITCHING
|
|
417
|
+
else runtime
|
|
415
418
|
)
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
for view, command in (
|
|
420
|
+
(
|
|
421
|
+
setup,
|
|
422
|
+
(
|
|
423
|
+
f"mkdir -p /logs/verifier {ARTIFACTS_DIR} && "
|
|
424
|
+
f"chmod 777 /logs/verifier {ARTIFACTS_DIR}"
|
|
425
|
+
),
|
|
426
|
+
),
|
|
427
|
+
(
|
|
428
|
+
runtime,
|
|
429
|
+
(
|
|
430
|
+
"rm -f /logs/verifier/reward.json /logs/verifier/reward.txt && "
|
|
431
|
+
f"{stage}"
|
|
432
|
+
),
|
|
433
|
+
),
|
|
434
|
+
):
|
|
435
|
+
result = await view.run(["sh", "-c", command], {})
|
|
436
|
+
if result.exit_code:
|
|
437
|
+
raise TaskError(
|
|
438
|
+
f"staging tests failed (exit {result.exit_code}): "
|
|
439
|
+
f"{(result.stderr or result.stdout).strip()[-500:]}"
|
|
440
|
+
)
|
|
422
441
|
|
|
423
442
|
@reward(weight=1.0)
|
|
424
443
|
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.
|
|
3
|
+
Version: 0.4.2.dev7
|
|
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
|
|
@@ -145,7 +145,7 @@ verifiers/v1/runtimes/compose.py,sha256=ttKfNBFGL1wGRX7Ek4oguENMjwRgb2Epp2SWZ8PL
|
|
|
145
145
|
verifiers/v1/runtimes/deployment.py,sha256=HnofN0L4ubKT0O370Liby06c9kkgbMtH3jB4bI1eJck,7466
|
|
146
146
|
verifiers/v1/runtimes/egress.py,sha256=4zsNS3Z2A2HyoCcbgaLizA30uJabYrbgYAYUfvyzeBk,23703
|
|
147
147
|
verifiers/v1/runtimes/limiters.py,sha256=RWR4HdYoa72yeWF_lM7YRLflm10euE3_gPfNG0BuaOc,2742
|
|
148
|
-
verifiers/v1/runtimes/native_compose.py,sha256=
|
|
148
|
+
verifiers/v1/runtimes/native_compose.py,sha256=OOLw6or1Prpx6YIbXqaY_nn7WVZF-LfjbqWibdJ_viA,42307
|
|
149
149
|
verifiers/v1/runtimes/private_network.py,sha256=8r8VODHB5k5WqbwJIx-dmMcPJKPNsIVbDu3JdrQLU2Y,6613
|
|
150
150
|
verifiers/v1/runtimes/runtime.py,sha256=-CvhH42y0F0dPeNgDRVBeajkRK_vZYp2qxKY1XVf-s0,9897
|
|
151
151
|
verifiers/v1/runtimes/strategies.py,sha256=nQC_dsuYwpPz46js2LNY5nuGyFXv8znKU7_xH5s9aVk,8624
|
|
@@ -155,7 +155,7 @@ verifiers/v1/runtimes/backends/prime.py,sha256=Lf92Wo64W9rgejTE5KBVZFqfCDaQYmRYi
|
|
|
155
155
|
verifiers/v1/runtimes/backends/subprocess.py,sha256=naOWJGmcaOlu2ZdRbUwhJicJdxASDRAUhDT0jzDff3w,8591
|
|
156
156
|
verifiers/v1/tasksets/__init__.py,sha256=2ijE3qIlLoUA02g6iysOwWQylyBBQL1GhSpjv8_bp0w,521
|
|
157
157
|
verifiers/v1/tasksets/harbor/__init__.py,sha256=FjW4tM3rgGALMK-8p7ux26G4-d4ZFVmaAmO6Fni6e_g,214
|
|
158
|
-
verifiers/v1/tasksets/harbor/taskset.py,sha256=
|
|
158
|
+
verifiers/v1/tasksets/harbor/taskset.py,sha256=z65yNIL7ARd6katDna0QTpLL_7rCo2GsfsrW7dqBCf8,43340
|
|
159
159
|
verifiers/v1/tasksets/harbor/toolset.py,sha256=_7HXu-uuvqzhmJ1EX6c3KWLg0g0eRrLjCq1kBsZhIwo,3159
|
|
160
160
|
verifiers/v1/tasksets/nemo_gym/__init__.py,sha256=654gAvG3Wd_Z_nh6mypeKn4s_IIQ0Ge6vcZvxTHC2_E,306
|
|
161
161
|
verifiers/v1/tasksets/nemo_gym/response.py,sha256=EhrsquEP8g0bjzAThGfE6Ypgy86_nVX235NiFYtVDVM,4463
|
|
@@ -189,8 +189,8 @@ verifiers/v1/utils/scope.py,sha256=ivYGJ8GhzyRKbP4L48VsUDWFxpmFsjeaE_7KYBKJ_c0,8
|
|
|
189
189
|
verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
|
|
190
190
|
verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
|
|
191
191
|
verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
|
|
192
|
-
verifiers-0.4.2.
|
|
193
|
-
verifiers-0.4.2.
|
|
194
|
-
verifiers-0.4.2.
|
|
195
|
-
verifiers-0.4.2.
|
|
196
|
-
verifiers-0.4.2.
|
|
192
|
+
verifiers-0.4.2.dev7.dist-info/METADATA,sha256=cuv0RX3ox-W-mK7fZZzvd7KKrbeAVbk9RtFnFlCsiJw,5136
|
|
193
|
+
verifiers-0.4.2.dev7.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
194
|
+
verifiers-0.4.2.dev7.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
|
|
195
|
+
verifiers-0.4.2.dev7.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
|
|
196
|
+
verifiers-0.4.2.dev7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|