Skip to content

feat(harbor): dataset-level task_data.py validated at materialize, seed and collate (M32) - #4864

Merged
adil-a merged 1 commit into
adasif/harbor-m30-compose-overlayfrom
adasif/harbor-m32-task-data
Oct 28, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m30-compose-overlayfrom
adasif/harbor-m32-task-data

Conversation

@adil-a

@adil-a adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

A Gym-authored Harbor dataset may ship task_data.py beside dataset.toml, a module exporting one Pydantic model TaskData that types the task-owned fields of its rows (RFC M32). A task carries those fields in task_data.json in its folder; the loader writes them into the row's task_data beside the reserved _ng_* keys. The same check runs at the three points a row crosses a boundary: materialize refuses the dataset naming the task, the environment server refuses the episode at seed, and gym dataset collate reports the row. A dataset without the module (every hub dataset) behaves as before.

What changes

  • nemo_gym/tasks/harbor/task_data.py (new): load_task_data_schema imports the dataset's module once (path-derived module name) and returns a TaskDataSchema; TaskDataSchema.validate strips the reserved keys, refuses undeclared keys whatever the model's extra setting (a field's name and every name its aliases admit, AliasChoices and AliasPath included, are declared), and names the task, the file and the failing fields (a validator that raises something pydantic does not wrap, such as a KeyError from a lookup, is the same TaskDataError with the exception named, so prepare refuses the dataset, the seed fails terminally and collate reports the row instead of a traceback or a retry); check_task_folders checks the folders' task_data.json before the tasks load; read_task_fields reads a task's task_data.json (JSON object, reserved keys refused); check_row_matches_folder pins a row's fields to its folder's; DatasetRowValidator is the collator's validator.
  • Loader: HarborTask.task_data; task_data.json enters the task digest (a folder without one keeps its digest).
  • Materialize: the row's task_data carries the task's fields under the reserved keys. prepare_target imports the schema after the manifest check and checks every task folder's task_data.json against it before any base image is recorded or built (and the loaded tasks again before the rows are written): a violating task refuses the whole dataset, named, with no image resolved, built or pushed; a module that does not import refuses it too.
  • Seed: the harbor environment server imports each taskset's module at startup (logged once when it fails) and validates every row before anything is provisioned: a row the model rejects, or whose fields differ from the pinned folder's task_data.json, is a terminal seed failure (422); a taskset whose module does not import refuses every episode with the import error.
  • Collate: _task_data_validator_for wraps the server's validator in a DatasetRowValidator when the dataset ships a model, validating task_input.task_data into the same report without reporting the dataset's declared fields as unknown keys; a module that does not import fails the collation.
  • Docs: harbor README ("Typed task fields", the settings table) and the Harbor tasks page (dataset layout, a new section).

Test plan

  • tests/unit_tests/test_harbor_task_data.py (37 new): loading, validation messages (aliases of every kind declared; a validator raising KeyError wrapped at validate, check_task_folders, prepare and collate), the loader's task_data.json, prepare_target refusals (a non-importing module and a violating row both refused before any image is recorded or built), row/folder pinning, and collate through the generated run config blocks. Core files together: 847 passed (plus the two env.yaml-dependent validation tests, 34 passed without it).
  • environment_servers/harbor/tests/test_task_data.py (10 new): typed row seeds and scores; wrong type, undeclared key, missing field, edited row, plain task with fields, a non-importing module and a validator that raises KeyError are terminal seed failures before any sandbox; the digest still wins. Env server + oracle suites: 441 passed.
  • ruff check, ruff format --check, pre-commit on the changed files.
  • Live on OpenSandbox with the oracle: a one-task typed dataset materializes with its fields in task_data, seeds and scores 1.0 (oracle solved), as does a copy whose answer is declared through AliasChoices and written as expected_answer; a copy with an undeclared key is refused by gym dataset validate at prepare before any base image is resolved, as is one whose validator raises KeyError (exit 2, the task named, no traceback); gym dataset collate +task_data_validation=error passes the rows and fails an edited row naming the task.

🤖 Generated with Claude Code

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7cd9d6c

@adil-a
adil-a added this pull request to stack #4793 October 21, 2026 16:26
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 21, 2026 16:36
@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work waiting-on-maintainers Waiting on maintainers to respond labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ca80274

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 96ff98c

@adil-a

adil-a commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test be30ebc

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working through yuhezhang-ai's findings; all five look addressed at be30ebc, and the focused core and server tests pass locally. The main open question is type conversion: validation accepts converted values but the rows keep the raw ones, so a typed field can reach the verifier with the wrong type. The rest are smaller questions about collate's warn mode and compatibility notes.

One more, on a line outside this diff: since task_data.py now decides whether a dataset's rows are accepted, would it make sense to include it in the dataset digest (manifest.py), so _ng_dataset_digest provenance records the schema version too?

Comment thread nemo_gym/tasks/harbor/task_data.py Resolved
Comment thread nemo_gym/tasks/harbor/materialize.py Resolved
Comment thread nemo_gym/train_data_utils.py Resolved
Comment thread environment_servers/harbor/app.py Resolved
@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3ec4a4f

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0dc8e2c

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test df66675

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e0574e1

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a6d31c0

yuhezhang-ai
yuhezhang-ai previously approved these changes Oct 26, 2026

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes. Rechecked a6d31c0 against its current stack parent: all five original findings are addressed, and the targeted regressions pass. Approving this layer.

Two nonblocking follow-ups: the strict-model/date edge case noted inline, and refreshing the PR description to match the current alias handling, warn/error behavior, and compatibility note for manually edited rows. Neither needs to hold up this approval. I did not rerun live model or sandbox validation in this follow-up.

Comment thread nemo_gym/tasks/harbor/task_data.py Resolved
@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 82530d2

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 64e9881

ffrujeri
ffrujeri previously approved these changes Oct 26, 2026

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Server suite shard 0 failed on test_a_seed_slower_than_the_ready_timeout_leaves_the_turns_their_budget (1s deadline), which looks like a timing flake; worth a rerun.

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 807cc4a

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Re the shard-0 flake: test_a_seed_slower_than_the_ready_timeout_leaves_the_turns_their_budget had 0.8 s of headroom under its 1.2 s post-seed budget for two verifier passes plus file I/O. Its step budgets are widened from 0.3 s to 0.5 s (1.6 s headroom) in 2e24547 on #4951, where the test file is owned; the failed job here was re-run meanwhile.

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 197a654

yuhezhang-ai
yuhezhang-ai previously approved these changes Oct 26, 2026

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. Rechecked 197a654 against its current stack parent, 9ea1b8f: all five original findings and the strict-model/date follow-up are addressed. The focused regression tests pass, including valid JSON date strings with an explicitly strict model.

LGTM for this layer. One nonblocking follow-up: please refresh the PR description to reflect the current alias handling, warn/error behavior, and compatibility note for manually edited rows.

I did not rerun live model or sandbox validation in this follow-up.

ffrujeri
ffrujeri previously approved these changes Oct 26, 2026

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 671454f

@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7cc0869

@adil-a

adil-a commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0bc9b65

@adil-a

adil-a commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ba2b396

ffrujeri
ffrujeri previously approved these changes Oct 27, 2026

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40537277312

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40546203857

…ed and collate (M32)

A Gym-authored dataset may ship task_data.py beside dataset.toml, a module
exporting one Pydantic model TaskData that types the task-owned fields of its
rows. A task carries those fields in task_data.json in its folder (the file
enters the task digest); the loader writes them into the row's task_data
beside the reserved _ng_* keys.

The same check runs at the three points a row crosses a boundary:
- prepare imports the module once per dataset and checks every task folder's
  task_data.json against it before any image is recorded or built (the loaded
  tasks again before a row is written), and refuses the whole dataset naming
  the task whose fields do not satisfy the model, carry an undeclared key
  (whatever the model's `extra` setting; a field's name and every name its
  aliases admit, AliasChoices and AliasPath included, are declared) or when
  the module does not import;
- the harbor environment server imports each taskset's module at startup and
  validates every row at seed: a row the model rejects, or whose fields are
  not the pinned folder's task_data.json, is a terminal seed failure (422)
  before anything is provisioned; a module that does not import refuses every
  episode of its taskset;
- gym dataset collate validates the taskset's rows against the server's
  reserved keys and the dataset's TaskData in one report (DatasetRowValidator),
  without reporting the dataset's declared fields as unknown keys.

A dataset without task_data.py (every hub dataset) behaves as before. The
module is imported, not parsed, with no static import guard (decision: it is
a plain Pydantic class loaded by Gym).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e44fbfa

1 similar comment
@adil-a

adil-a commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e44fbfa

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Rechecked e44fbfa against its current stack parent, 0678258. This PR's changes are unchanged from the previously reviewed layer, and the fixes for all five original findings and the strict-model/date follow-up remain intact.

The PR-description refresh remains a nonblocking follow-up: alias handling, warn/error behavior, and the compatibility note for manually edited rows should reflect the current implementation.

This was an incremental source recheck using the earlier focused test results; I did not rerun the full stack or live model/sandbox validation.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40609236053

This branch was previously deployed

1 inactive deployment
public — e44fbfac Deployed Oct 27, 2026 by copy-pr-bot[bot] via release / finalize / notify #7654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work QA_verified waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants