Repository navigation
fix(data): collate validates task_data from any cwd; a data-only dir no longer shadows the server dir - #5325
Conversation
|
/ok to test 70b2ebb |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found. Reviewed all five changed files and traced component-search precedence, schema ownership, validation modes, metrics-hook loading, and collation routing. The external-cwd regression cases distinguish rejected invalid rows from accepted valid rows while retaining schema-only plugin support.
Static inspection only; tests were not executed. All three delegated inspections terminated; two returned no report payload, so their resolver and schema/metrics topics were independently inspected by the root reviewer.
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 full review. Request a full review with /review reset=true.
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for the careful write-up and the before/after matrix. The fix is correct and minimal. find_server_dir now skips a directory that holds only collate's own output, so from any cwd the lookup lands on the real server directory and the task_data.py gate runs again. The environment_servers schema lookup in _schema_home_for goes through the same resolver, so it gets the fix too.
What we checked on 70b2ebb9e5:
- Real CLI repro: ran
gym dataset collate --resources-server mcqa --mode example_validationfrom an empty directory outside the checkout, with a misspelledgrading_modeon one row. On this head it exits 1 with the schema error. On main it exits 0 and the bad row is collated. - Tests:
tests/unit_tests/test_task_data.pyandtest_train_data_utils.pypass at this head (474 passed). Against main'stask_data.pyandtrain_data_utils.py, the new shadow, warning, and external-cwd negative tests fail, so they are real regression tests. - Built-in servers: every built-in directory under
resources_servers/,responses_api_agents/andenvironment_servers/has at least one of the markers, so built-in lookups are unchanged.
The three inline notes are small (warning hint text, one docs sentence, test coverage of the marker list). None of them blocks merging.
Possible follow-up, not for this PR: the <stem>_metrics.json drift check has the same from-any-cwd gap. It reads only the cwd-relative sidecar (train_data_utils.py#L981, #L873). So from an external cwd, the committed example_metrics.json under the install root is never compared, and a fresh sidecar is written instead. Reading the sidecar through _resolve_under_cwd_or_install, while still writing it to the cwd, would close that gap.
|
This is ready to approve except for one thing: #5189 moved |
|
/ok to test 15dde46 |
…erver-dir marker The "no server directory" warning told users to check the resources_server reference, which cannot be the cause when it fires: a dangling reference never reaches it (_schema_home_for returns None first). The validator and the metrics-hook warnings now share one hint that names the implementation the instance resolves to and the search-root remedy. prepare-validate.mdx no longer promises a warning when a deprecated agent_ref is stripped (it is a DeprecationWarning, hidden by Python's default filters), and step 5 says rows are stamped with task_source rather than agent references. Tests: a cwd directory holding only one marker resolves, for each of the four markers spelled out; a marker that is a directory does not count; a found server without task_data.py is skipped without any warning. Found in review of #5325 by yaoyu-33. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
70b2ebb to
15dde46
Compare
|
/ok to test ca65432 |
|
Merged 🤖 Addressed by Claude Code |
…uz/nvb-6900465-collate-schema-dir-shadow
|
/ok to test 45c76ab |
Conflict in tests/unit_tests/data/test_task_data.py: both sides appended tests at the end of the file. Kept the PR's TestFindServerDirRejectsOutputOnlyDirs and TestExternalCwdThroughTheProcessor and main's test_rl_stream_index_is_not_part_of_task_schema (#6091). Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
|
/ok to test c02f3fb |
yaoyu-33
left a comment
There was a problem hiding this comment.
LGTM. Re-reviewed the latest head; the previous comments are addressed. All 549 task-data and dataset-preparation tests passed, including external-cwd validation.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44431912731 |
|
/ok to test 2530b86 |
…be the shadow after #5997 #5997 made output_dir a required keyword of _collate_samples_single_type and moved the prepared file into the run's output directory, so collate no longer creates <cwd>/<base_folder>/<server>/data/ itself. The two external-cwd tests now pass output_dir like their siblings, and the resolver's docstring and the test docstrings say where such a directory still comes from: an earlier collate run, or a dataset kept under resources_servers/<server>/data/. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
|
/ok to test 489e290 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44589813756 |
|
Retrospective QA-fix tracking issue: #6589 |
What does this PR do?
gym dataset collate --mode example_validationnow rejects a row that violates the owning server'stask_data.pyschema from any cwd. Before, running collate from a cwd outside the checkout (a project directory, the QA runner's scratch workspace) collated the row and exited 0 without a word, because the schema lookup resolved to the data-only directory collate had just created for its own sidecars.Fixes NVBug 6900465.
Cause
_collate_samples_single_typewrites<stem>_prepare.jsonlnext to the cwd-relativejsonl_fpathand creates that directory (<cwd>/resources_servers/<server>/data/) right before it looks the schema up.find_server_dir(nemo_gym/task_data.py) resolvedresources_servers/<server>withvalidator=Path.is_dir, and the component search roots put the cwd before the install root, so the freshly created output directory won,load_task_data_schemafound notask_data.pyin it and returnedNone, and_task_data_validator_forskipped validation silently. The same lookup serves_dataset_metrics_hook_for. Both the resolver and the mkdir-before-lookup order date from #2795, which introduced collate validation.Update (2026-11-18): since #5997 (
4e3f503549, merged 2026-11-17) collate writes the prepared file and the metrics sidecar into the run's output directory, so it no longer creates that directory itself. The shadow still happens wherever such a directory exists: left behind by an earlier collate run (thelsbelow shows one), or a dataset kept underresources_servers/<server>/data/in the project directory. The resolver fix and the warning are unchanged; the two external-cwd tests now passoutput_dir, which #5997 made a required argument, and the docstrings describe the mechanism as it stands.The NVBug's other defect (the owning resources server of an agent-declared dataset was looked up in the in-scope-filtered instance list) was fixed on main by #3674 (
_schema_lookup_configs); the matrix below confirms it, so this PR does not touch it.Fix
find_server_diraccepts a candidate only when it holds a server source marker:requirements.txtorpyproject.toml(the rulenemo_gym/cli/env.py::_resolve_server_diralready applies), or the module being looked up (task_data.py,dataset_metrics.py) so a plugin server that ships only a schema still resolves. Every built-inresources_servers/,responses_api_agents/andenvironment_servers/directory carries at least one marker, so built-in lookups are unchanged; a directory holding only Gym's output can no longer shadow them._task_data_validator_forand_dataset_metrics_hook_forwarn when a schema home resolves to no server directory at all (previously a silentNone), so the gate cannot switch off without a trace again. The shared hint names the implementation the instance resolves to and the search-root remedy (a danglingresources_serverreference never reaches this warning). Servers without atask_data.pyare still skipped silently, as documented.Docs (
225a46c84):fern/versions/latest/pages/data/prepare-validate.mdxsaid collate "adds theagent_reffield to each row"; since feat(data): collate stamps task_source; datasets declarable on resources servers #2717 collate stampstask_sourceand strips a deprecatedagent_ref, so the sentence now says that and mentions thetask_data.pycheck; step 5 of the "steps" list says the same. Found while checking this PR against the page.Review follow-up (
15dde46a3, @yaoyu-33): the warning hint named theresources_serverreference as the thing to check, which cannot be the cause when the warning fires; it now names the implementation (one helper for both warnings). The docs no longer promise a warning for a strippedagent_ref(it is aDeprecationWarning, hidden by Python's default filters). Tests pin every entry ofSERVER_DIR_MARKERSby name (a cwd directory holding only that file resolves; a marker that is a directory does not) and the documented silent skip of a found server withouttask_data.py; removing any one marker from the tuple now fails at least one test.Rejected alternatives: validating only on the looked-up module (
task_data.py) would make a server that ships a schema but, by mistake, under another name indistinguishable from a shadow; resolving write targets differently was out of scope here (_resolve_under_cwd_or_installis documented as read-only); #5997 has since moved the prepared file and the metrics sidecar into the run's output directory.Before the fix
Gym
f70bf75c3(main). The mcqa example dataset withgrading_mode: "strict_single_leter_boxed"(typo) on row 0 and itsexample_metrics.jsonremoved; from an empty directory outside the checkout:The typo row is in
collated/example.jsonl. Same result for an undeclaredbogus_task_fieldon every row ofexample_single_tool_call(agent-declared) and for a missing requiredexpected_countinexample_session_state_mgmt(resources-server-declared,--config .../example_session_state_mgmt_nooa.yaml). From the checkout root all three fail correctly, which is the #3674 state.After the fix
Gym
61e01f8bf(this branch; the log below was captured at its pre-rebase form6a0a5f286on main5911d628c, the logic is unchanged since), same command from the same external directory:Full matrix (exit codes), four datasets × {checkout root, external cwd}: before
1 0 / 1 0 / 1 0 / 1 0, after1 1 / 1 1 / 1 1 / 1 1.Validation
dataset_collate(local lane, no model): the three existing cases pass before and after; two new negative controls (schema-violating row in an agent-declared and in a resources-server-declared dataset, collated from the scratch workspace cwd) fail on mainf70bf75c3(3/5: both controls report "collate exited 0 on a schema-violating row (validation skipped)") and pass on this branch (5/5). They land in nmfw_tests after the merge.pytest tests/unit_tests/test_task_data.py tests/unit_tests/test_train_data_utils.py tests/unit_tests/test_indic_ifeval.py: 506 passed at15dde46a3on main283147705(15 new: shadow dir under cwd for a resources server and for an agent, schema-only plugin dir, missing server, unresolvable schema home warns, external-cwd collate rejects a violating row and passes a clean one, each of the four markers alone resolves a cwd server dir, a marker that is a directory does not; one existing test,test_agent_without_rs_reference_and_no_schema_is_skipped, now builds a real marker-bearing server dir instead of an empty directory that shadowed the built-intau2, and asserts the skip is silent). The repo sweepTestRepoDataMatchesSchemasstill passes, so the committed example data stays clean under the restored gate.pre-commit run --all-files: passed.python tests/unit_tests/test_fern_docs_links.py29 OK;npm run checkinfern/passed.Compatibility
Collate runs from outside the checkout that used to exit 0 on schema-violating rows now fail in
example_validationmode and print the per-file report intrain_preparationmode, as thetask_data_validationoption already documents. A user's own server directory needs one ofrequirements.txt,pyproject.toml,task_data.pyordataset_metrics.pyto be found by the data tooling; every built-in server has one.🤖 Generated with Claude Code