fix: gym dataset collate creates the artifact dir when missing (run-from-wheel)#1811
Merged
Conversation
Completes the run-from-wheel story (epic #1205 C5). `gym env start` of a built-in already works once nemo-gym is published (setup_command's non-editable path installs `nemo-gym==<version>` from the index); this fixes the two remaining tooling gaps: - gym env test: the per-server venv installed bare `nemo-gym` from the index, dropping the `[dev]` extra, so `&& pytest` failed (exit 127). Add an opt-in include_dev_extra to setup_env_command; _test_single passes it so the test venv gets pytest. gym env start stays lean (no test deps). - gym dataset collate: the per-dataset artifact writes (_metrics.json / _prepare.jsonl, derived from the raw cwd-relative jsonl_fpath) crashed with FileNotFoundError when the dir didn't exist in the cwd (e.g. a built-in dataset resolved from the install root via #1806). mkdir(parents) the artifact dir before writing. Tests: include_dev_extra installs nemo-gym[dev]; collate creates a missing parent dir. Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
Per review: pulling nemo-gym's [dev] extra (pre-commit/mypy/ruff + the pytest deps) into every per-server test venv is too coarse just to get pytest for `gym env test` from a wheel. Reverting the setup_command/_test_single `include_dev_extra` change; `gym env test` from a wheel (a contributor-runs-in-repo edge case) stays a documented limitation. PR #6 now only fixes the clear `gym dataset collate` write crash (mkdir). Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
marta-sd
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final piece of the "use built-in components from a
pip installof NeMo Gym" work (epic #1205, criterion C5). After #1806 (merged) made a dataset's read resolve to the install root,gym dataset collateon a built-in dataset from an external cwd would then crash on the write: the derived artifacts (_metrics.json,_prepare.jsonl) are built from the raw, cwd-relativejsonl_fpathandopen(..., "w")with nomkdir, so they hitFileNotFoundErrorwhen that directory doesn't exist in the cwd.Fix:
mkdir(parents=True, exist_ok=True)the artifact directory before writing (theoutput_dirpathwrite was already guarded). For the common case (collating your own dataset in your project) it's a no-op; it just prevents the crash for the install-root-resolved case.Tests
test_collate_creates_missing_parent_dir— collate auto-creates a missing artifact parent instead of crashing.ruff clean;
test_train_data_utils+test_cli_setup_commandgreen. 2 files, +26.Scope notes (verified, intentionally not in this PR)
gym env startof a built-in from a wheel already works —setup_command's non-editable path installsnemo-gym==<version>from the index; it just needs a published version (verified empirically). No code change needed.gym env testof a built-in from a wheel — the per-server test venv lackspytest(it's only in the[dev]extra). Deliberately left out: pulling all of[dev](pre-commit/mypy/ruff + test deps) into every test venv is too coarse, and running a built-in's tests from a wheel is a contributor-in-repo edge case. Can be revisited with a narrow[test]extra if needed.