Repository navigation
feat(eval): add IsolatedExporter to run an exporter's backend work in its own venv - #4915
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
316afc9 to
af9e0da
Compare
|
/ok to test af9e0da |
af9e0da to
56082d4
Compare
|
/ok to test 56082d4 |
56082d4 to
1722973
Compare
7a91c30 to
192fbf0
Compare
192fbf0 to
bc45a44
Compare
bc45a44 to
18e049b
Compare
|
|
||
| def __init__(self, config: RunExportConfig, *, venv_root: Path) -> None: | ||
| super().__init__(config) | ||
| self.venv_root = Path(venv_root) |
There was a problem hiding this comment.
why not Path(venv_root).resolve()? Without resolve(), a relative path override +uv_venv_dir=./venvs makes the worker launch look for the exporter's Python in the wrong folder and crash with FileNotFoundError
There was a problem hiding this comment.
Agreed, and good catch. venv_root is now Path(venv_root).resolve() in __init__, so a relative +uv_venv_dir=./venvs points at the right interpreter after the launch changes into the staging directory. Fixed in b4e627b, with a test that runs the exporter from a relative root.
18e049b to
506cb4d
Compare
agronskiy
left a comment
There was a problem hiding this comment.
Review by Alex Gronskiy (EvalRDL side).
_isolated_worker.py
- The fix that drops the harness's own directory from
sys.pathlands in #4965, but this PR introduces the bug:mlflow.pyandwandb.pyalready sit next to the harness, so a worker importing those SDKs would import Gym's modules instead. Move the fix and its regression test here.
isolated.py
_run_workerhas no timeout (listed as a known gap). The EvalRDLtimeoutsetting only limits the wait for the service's verdict; the upload itself (parts, retries) has no overall limit. Before #7's job-script tail lands,subprocess.run(timeout=...)at roughly the config timeout plus a margin would stop a hung upload from consuming the Slurm allocation.
Otherwise LGTM.
|
Thanks. Both addressed in 6e56806:
|
… its own venv The SDK and its dependencies stay out of Gym's environment. The main process validates the config and stages files; a stdlib-only harness runs the exporter's worker in a locked, requirements-keyed venv, with the JSON payload on stdin and the result in a file. Signed-off-by: Tomasz Grzegorzek <[email protected]>
Anchor the venv root, interpreter and worker file to absolute paths before the launch changes into the staging directory, put the exporter venv first on the worker's PATH, register the worker module in sys.modules so dataclasses and postponed annotations work, fail a worker that reports a result but then exits non-zero, and return a failed result when the worker cannot be launched. Signed-off-by: Tomasz Grzegorzek <[email protected]>
… the worker's run time mlflow.py and wandb.py sit beside the harness, so a worker importing those SDKs would have loaded Gym's modules instead. An exporter can now give its worker a time limit; a worker that outlives it is killed and the export fails. Signed-off-by: Tomasz Grzegorzek <[email protected]>
|
/ok to test bb5aa0a |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — no remaining eligible findings in this follow-up.
Verified all five prior findings against current source and regression assertions:
- Launch and environment handling now anchors paths, selects the exporter venv for executable lookup, converts launch errors to failed results, and rejects success/skipped results followed by nonzero exits.
- Worker loading registers the module before execution, addressing postponed-annotation dataclasses.
Also checked harness-directory removal and optional timeout handling through their affected import, failure-reporting, and staging-cleanup paths, with the relevant regression cases.
Static review only; tests were not executed. The previously reviewed tree is unavailable, limiting independent inter-review comparison. This review verified the reported fixes and identifiable subsequent changes rather than restarting whole-PR discovery; no new escalation-eligible regression was established.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
agronskiy
left a comment
There was a problem hiding this comment.
Review by Alex Gronskiy (EvalRDL side). Both points are addressed, thanks. LGTM.
Optional nit: the timeout message prints exc.timeout, which some Python versions report as the remaining time (0.999936s locally on 3.12). Printing self.worker_timeout_s(payload) makes it stable.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40685749063 |
Summary
IsolatedExporter(nemo_gym/exporters/isolated.py): an exporter whose backend work runs in its own venv, so its SDK never enters Gym's environment. A subclass declaresrequirements,worker_fpathandbuild_payload(artifacts, workdir); config validation and file staging stay in the main process, and the staging directory is removed afterwards._venv_setup.setup_environment()(locked, reused when ready) at<uv_venv_dir>/exporters/<name>/<requirements digest>/.venv; a changed requirement list gets a fresh venv.run(payload) -> dict, run by a stdlib-only harness (_isolated_worker.py). The payload goes in on stdin (credentials stay out ofps) and the result comes back in a file (SDK output cannot corrupt it).PYTHONPATH,PYTHONHOMEandVIRTUAL_ENVare not inherited.failedresults instead of raising. A worker that reports a result but then exits non-zero fails too.uv_venv_dirworks. The exporter venv'sbinleads the worker'sPATH, so a barepythonis the exporter's. The worker module is registered insys.modules, so dataclasses with postponed annotations load.sys.path, becausemlflow.pyandwandb.pybeside it would otherwise shadow the SDKs of the same name.worker_timeout_s(payload); a worker that outlives it is killed and the export fails. The default is no limit.Nothing uses it yet; EvalRDL (step 6) is the first user. Part of #2977 (export-aware evaluation runs).
PR plan
Separate PRs; steps 1-8 are stacked (stack #4910). Goal: make
gym eval exportpluggable so a finished run can go to tracking systems without live exporters, andgym eval submitcan export after each benchmark.gym eval run(feat(eval): save the masked config beside rollouts from gym eval run #4908)RunArtifactsand path derivation helpers (feat(eval): add RunArtifacts to derive a run's files from its rollouts path #4909)Exporterbase class and registry, starting withatif, plus the positional exporter CLI argument (--formatdeprecated) (feat(eval): add the Exporter base class and registry, with atif as the first exporter #4911)mlflowandwandbexport: shared metrics flattening,BaseExporter.export()and the already-exported guard (feat(eval): export a finished run to MLflow or W&B with gym eval export #4914)gym eval submitintegration: anexportmap with job-level defaults and per-benchmark overrides, validation, install extras, and a job-script tail (Slurm only at first) (feat(orchestration): run exports after each benchmark of gym eval submit #4974)Validation
test_isolated_exporter.py: 19 passed, building a real venv and running a real worker (also: relative venv root and worker path, a barepythonresolving to the exporter venv, dataclasses with postponed annotations, a non-zero exit after a result, a launch failure, the harness directory offsys.path, the time limit): differentsys.prefix, nonemo_gymimport, noPYTHONPATH, venv reused, staging removed,skipped/failed/success round-trip, worker exception and crash, failed build, unpreparable run.pre-commit: passed.Known gaps
worker_timeout_sdefaults to none); EvalRDL sets one in feat(eval): export a finished run to EvalRDL with gym eval export evalrdl #4965.Rollout evidence
N/A: no agent, verifier or model behavior is touched.