verifiers 0.3.2.dev64__py3-none-any.whl → 0.3.2.dev65__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.
@@ -32,6 +32,7 @@ from verifiers.v1.runtimes import (
32
32
  )
33
33
  from verifiers.v1.runtimes.base import _ENSURE_UV
34
34
  from verifiers.v1.state import State
35
+ from verifiers.v1.utils.aio import run_shielded
35
36
 
36
37
  if TYPE_CHECKING:
37
38
  from verifiers.v1.mcp.toolset import Toolset
@@ -188,35 +189,36 @@ async def _install_in_sandbox(server: ServerBase, runtime: Runtime) -> str:
188
189
  root = str(PurePosixPath(workdir) / ".vf-src")
189
190
  temp = str(PurePosixPath(workdir) / ".vf-tmp")
190
191
  cache = str(PurePosixPath(workdir) / ".vf-uv-cache")
191
- vf, env = _verifiers_root(), Path(source_dir)
192
- vf_name, vf_data = await _cached_sdist(vf)
193
- if env == vf:
194
- env_name, env_data = vf_name, vf_data
195
- else:
196
- env_name, env_data = await _cached_sdist(env)
197
- vf_remote = f"{root}/{vf_name}"
198
- env_remote = f"{root}/{env_name}"
199
- await runtime.write(vf_remote, vf_data)
200
- if env_remote != vf_remote:
201
- await runtime.write(env_remote, env_data)
202
192
  venv = str(PurePosixPath(workdir) / ".vf-venv")
203
193
  root_q, temp_q, cache_q, venv_q = map(shlex.quote, (root, temp, cache, venv))
204
- vf_source = shlex.quote(vf_remote)
205
- env_source = shlex.quote(env_remote)
206
- setup = (
207
- f"set -e; mkdir -p {root_q} {temp_q} {cache_q}; "
208
- f"export TMPDIR={temp_q} UV_CACHE_DIR={cache_q}; "
209
- f"{_ENSURE_UV}; "
210
- f"uv venv {venv_q} && "
211
- f"uv pip install --python {venv_q} {vf_source} && "
212
- f"uv pip install --python {venv_q} {env_source}"
213
- )
214
- result = await runtime.run(["sh", "-c", setup], {})
215
- if result.exit_code != 0:
216
- raise ToolsetError(
217
- f"server {server.server_name!r} install failed in runtime: "
218
- f"{(result.stderr or result.stdout).strip()[-2000:]}"
194
+ # Colocated servers and borrowed views install into one physical environment.
195
+ # Serialize its mutations and only remember sources after a successful install.
196
+ async with runtime._mcp_install_lock:
197
+ sources = dict.fromkeys((str(_verifiers_root()), source_dir))
198
+ pending = [source for source in sources if source not in runtime._mcp_sources]
199
+ if not pending:
200
+ return f"{venv}/bin/python"
201
+ setup = (
202
+ f"set -e; mkdir -p {root_q} {temp_q} {cache_q}; "
203
+ f"export TMPDIR={temp_q} UV_CACHE_DIR={cache_q}; "
204
+ 'export PATH="$HOME/.local/bin:$PATH"; '
219
205
  )
206
+ if not runtime._mcp_sources:
207
+ # Failed installs can leave the venv behind; retain it when retrying.
208
+ setup += f"{_ENSURE_UV}; uv venv --allow-existing {venv_q}; "
209
+ # Drain remote writes and installs before cancellation releases the lock.
210
+ for source in pending:
211
+ name, data = await _cached_sdist(Path(source))
212
+ remote = f"{root}/{name}"
213
+ await run_shielded(runtime.write(remote, data))
214
+ setup += f"uv pip install --python {venv_q} {shlex.quote(remote)}; "
215
+ result = await run_shielded(runtime.run(["sh", "-c", setup], {}))
216
+ if result.exit_code != 0:
217
+ raise ToolsetError(
218
+ f"server {server.server_name!r} install failed in runtime: "
219
+ f"{(result.stderr or result.stdout).strip()[-2000:]}"
220
+ )
221
+ runtime._mcp_sources.update(pending)
220
222
  return f"{venv}/bin/python"
221
223
 
222
224
 
@@ -155,6 +155,8 @@ class Runtime(ABC):
155
155
  self.env: dict[str, str] = {}
156
156
  self._uv_interpreters: dict[str, str] = {}
157
157
  self._uv_script_locks: dict[str, asyncio.Lock] = {}
158
+ self._mcp_sources: set[str] = set()
159
+ self._mcp_install_lock = asyncio.Lock()
158
160
  self._setup_claimed = False
159
161
  self.stopped = False
160
162
  """Whether teardown has begun (set by `stop`). A stopped runtime is dead: a rollout
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.3.2.dev64
3
+ Version: 0.3.2.dev65
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
@@ -137,11 +137,11 @@ verifiers/v1/judges/reference.txt,sha256=Ej35kGXiT2uJ0LcHIeez49rCS_9uHmCQKoVdn93
137
137
  verifiers/v1/judges/rubric.py,sha256=HGQYI3xdq8I84Ce0_sDeNgk5JM597es8rOVPipjCyxU,12025
138
138
  verifiers/v1/judges/rubric.txt,sha256=3KA2ZeYYdcDweJhUGopxu9EFgARhu2aWft5S5cj8Bc8,323
139
139
  verifiers/v1/mcp/__init__.py,sha256=pm8ZWBiL1q1tY4wHvJzM_QrZ9oR8aGm-bIRWiRJsgHI,408
140
- verifiers/v1/mcp/launch.py,sha256=K6M8ZaoOO7wt65s93wK_9Wl7bvjeQ4C8BLkrGE149DI,23373
140
+ verifiers/v1/mcp/launch.py,sha256=gFkAdSZpFAxj5AAmL45Rh1dAttZVzoXJQPqgfY-jcGU,23866
141
141
  verifiers/v1/mcp/server.py,sha256=Jqi8OMT8DnoZegXqM3UNNRzhVnbdrPEwx0DjOJo_K2A,13256
142
142
  verifiers/v1/mcp/toolset.py,sha256=G2wzNdEMGLXoQUcrwF0TartJkqokNPI3o7YUOAaaa6U,1007
143
143
  verifiers/v1/runtimes/__init__.py,sha256=ppc1R_sx-aMcuJSx4t99rTSjloUXI0M6EUj676-1PeY,2862
144
- verifiers/v1/runtimes/base.py,sha256=kPxbK-VPr4j3Ah0SYlHAMefUJpVF6jTCJkZm7TRVeAs,17376
144
+ verifiers/v1/runtimes/base.py,sha256=VMxYMnGE_zj4k1VseTxEtKhzOZroahRnZSfvruDenEw,17468
145
145
  verifiers/v1/runtimes/limiters.py,sha256=C6cWDD4pwyFwUY4QFke3oiMXwydSNIfSbJSIglUC2kE,3062
146
146
  verifiers/v1/runtimes/modal.py,sha256=wUNik2Wul1YISausdABIMAoSaTA0MNDwKUayKxVLwAA,13342
147
147
  verifiers/v1/runtimes/prime.py,sha256=fbyR5s3WqsJNWki3eHJa83j4iobnqDugdJWm8GwEs7w,18494
@@ -189,8 +189,8 @@ verifiers/v1/utils/prime.py,sha256=UTYRjp9cbjNb6CVmBHda-1wWZAIIfxNOmTyNuT7_wL4,9
189
189
  verifiers/v1/utils/retries.py,sha256=Y2ZgrAjn-qNkRKZP_RVNL_7EK0iaRcZeCa404lpGYi4,5417
190
190
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
191
191
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
192
- verifiers-0.3.2.dev64.dist-info/METADATA,sha256=uYX4LJNV3yeutj3Pwcw8IU3Fbz-CYNSzBwOs5vX50nY,4204
193
- verifiers-0.3.2.dev64.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
194
- verifiers-0.3.2.dev64.dist-info/entry_points.txt,sha256=uqQje0TMsr7k6nXlWxlPs13Si0evb3pVCEDF6c-YL80,241
195
- verifiers-0.3.2.dev64.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
196
- verifiers-0.3.2.dev64.dist-info/RECORD,,
192
+ verifiers-0.3.2.dev65.dist-info/METADATA,sha256=_q3RXq8_fdd4hHeFaGrvSrklhdbyuW-pS1qImNqcvZ4,4204
193
+ verifiers-0.3.2.dev65.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
194
+ verifiers-0.3.2.dev65.dist-info/entry_points.txt,sha256=uqQje0TMsr7k6nXlWxlPs13Si0evb3pVCEDF6c-YL80,241
195
+ verifiers-0.3.2.dev65.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
196
+ verifiers-0.3.2.dev65.dist-info/RECORD,,