Skip to content

[Refactor] Split large test files into per-concept files#3747

Merged
vmoens merged 5 commits into
pytorch:mainfrom
vmoens:test-split-modules-rb
May 14, 2026
Merged

[Refactor] Split large test files into per-concept files#3747
vmoens merged 5 commits into
pytorch:mainfrom
vmoens:test-split-modules-rb

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented May 12, 2026

Summary

Splits four monolithic test files into per-concept modules under test/modules/ and test/rb/, mirroring the existing test/objectives/ and test/transforms/ layout. Pure file reorganization — no test logic changes.

Old file Lines New location
test/test_modules.py 1753 test/modules/test_{mlp_conv,rnn,planners,dreamer,multiagent,decision_transformer}.py (split across)
test/test_tensordictmodules.py 2952 test/modules/test_{td_module,rnn,decision_transformer,actor}.py
test/test_actors.py 1073 test/modules/test_{actor,qvalue_actor}.py
test/test_rb.py 6455 test/rb/test_{rb_core,storages,samplers,prioritized,writers,composable,rb_transforms,ensemble,distributed}.py
test/test_rb_distributed.py test/rb/test_distributed.py (moved; absorbs TestRayRB)
test/test_storage_map.py test/rb/test_storage_map.py (verbatim move)

Plus test/modules/_modules_common.py + conftest.py and test/rb/_rb_common.py + conftest.py for shared flags/helpers (pattern mirrored from test/objectives/_objectives_common.py).

.github/labeler.yml globs and setup.cfg per-file-ignores updated accordingly.

Test plan

  • pytest --collect-only test/modules/ returns 3025 tests (matches pre-split baseline exactly)
  • pytest --collect-only test/rb/ returns 4992 tests (matches pre-split baseline exactly)
  • ruff check test/modules/ test/rb/ — 6 findings, all pre-existing in source (same count as ruff check against the pre-split files)
  • Spot-run pytest test/modules/test_mlp_conv.py::TestMLP — 1729 passed
  • Spot-run pytest test/rb/test_rb_core.py::test_replay_buffer_read_write_all_in_order* — 2 passed
  • CI on this PR

Splits four monolithic test files into per-concept modules under
test/modules/ and test/rb/, mirroring the existing test/objectives/
and test/transforms/ layout. Pure file reorganization — no test logic
changes; pytest collection counts match pre-split baselines exactly
(modules: 3025; rb: 4992).

- test/test_modules.py, test/test_tensordictmodules.py, test/test_actors.py
  -> test/modules/test_{mlp_conv,rnn,planners,dreamer,multiagent,
       decision_transformer,td_module,actor,qvalue_actor}.py
  plus test/modules/_modules_common.py and conftest.py.

- test/test_rb.py, test/test_rb_distributed.py, test/test_storage_map.py
  -> test/rb/test_{rb_core,storages,samplers,prioritized,writers,
       composable,rb_transforms,ensemble,distributed,storage_map}.py
  plus test/rb/_rb_common.py and conftest.py.

- Update .github/labeler.yml globs (Modules -> test/modules/**,
  ReplayBuffers -> test/rb/**) and adjust setup.cfg per-file-ignores.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 12, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3747

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 12, 2026
@github-actions github-actions Bot added CI Has to do with CI setup (e.g. wheels & builds, tests...) ReplayBuffers Modules Refactoring Refactoring of an existing feature labels May 12, 2026
vmoens added 4 commits May 12, 2026 18:37
- test/modules/test_dreamer.py -> test_dreamer_components.py
  (basename clashed with test/objectives/test_dreamer.py — pytest could
  not import both modules with the same name in the absence of __init__.py)
- test/modules/test_multiagent.py -> test_multiagent_models.py
  (clashed with test/libs/test_multiagent.py)
- Run ufmt across the new files to satisfy the lint hook.
Same basename-collision issue as the previous commit: pytest cannot import
both test/test_distributed.py and test/rb/test_distributed.py with the same
module name. Preserve the original full basename (test_rb_distributed.py)
to keep it unique, and update run_all.sh accordingly.
…rb/test_samplers.py

PR pytorch#3749 added 6 new tests for RandomSampler/SliceSampler replacement-kwarg
dispatch to test/test_rb.py — which this branch deleted as part of the
split into test/rb/. Ported those 6 TestSamplers methods (plus the new
Sampler/RandomSampler imports) into test/rb/test_samplers.py.

All 6 ported tests pass locally; collection count rises from 225 to 231.
@vmoens vmoens merged commit 0bde4b4 into pytorch:main May 14, 2026
82 of 99 checks passed
@vmoens vmoens deleted the test-split-modules-rb branch May 14, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Has to do with CI setup (e.g. wheels & builds, tests...) CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Modules Refactoring Refactoring of an existing feature ReplayBuffers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant