Skip to content

Resolve tree_test golden-data paths relative to the test file - #130

Open
rootkiller6788 wants to merge 2 commits into
google-deepmind:mainfrom
rootkiller6788:fix-tree-test-data-path
Open

rootkiller6788 wants to merge 2 commits into
google-deepmind:mainfrom
rootkiller6788:fix-tree-test-data-path

Conversation

@rootkiller6788

Copy link
Copy Markdown

The tree tests can't currently be run the way CONTRIBUTING suggests picking affected tests individually: python -m pytest mctx/_src/tests/tree_test.py from the repo root fails on all four parametrized cases with FileNotFoundError.

The golden JSON trees are opened via paths like ../mctx/_src/tests/test_data/muzero_tree.json, which only resolve when pytest is launched from a directory below the repo root — that's why test.sh cd's into a _testing/ dir. This change resolves the data directory from the test file location instead, so the tests run from any working directory, both in the source tree and from an installed wheel (the package ships test_data/). CI via test.sh is unaffected.

While there I also removed a duplicated jax.random.split(rng_key, 3) line in _produce_prediction_output — same pure-function call twice, so the first assignment was dead code.

Verified: python -m pytest mctx/_src/tests/tree_test.py -q from the repo root now passes 4/4 (previously 4x FileNotFoundError).

The golden trees under test_data/ were opened with paths relative to the
process working directory (../mctx/_src/tests/test_data/...), which only
resolve when pytest runs from a directory below the repo root (test.sh cd's
into a _testing dir for this reason). Running the file from the repo root,
e.g. `python -m pytest mctx/_src/tests/tree_test.py`, therefore failed on
all four parametrized cases with FileNotFoundError.

Resolve the data directory from os.path.dirname(__file__) so the tests can
run from any working directory, both in the source tree and from an
installed package (the wheel ships test_data/).
_produce_prediction_output split rng_key three ways twice in a row. The
first assignment is dead code: jax.random.split is pure and both calls use
the same key, so the second result is identical to the first. Keep a single
split.
@rootkiller6788
rootkiller6788 marked this pull request as ready for review October 12, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant