Reorganize repository to match sMRIPrep and NiPost#1624
Open
tsalo wants to merge 16 commits into
Open
Conversation
Move xcp_d/ -> src/xcp_d/ and xcp_d/tests/ -> test/ to follow the fMRIPost/smriprep convention. Updates hatch build config, pytest testpaths, ruff ignores, coverage paths, CircleCI path filters, and Sphinx config to match the new layout. All moves done via git mv to preserve rename history. Also adds pythonpath=["."] to pytest config and updates all xcp_d.tests.* imports to test.* to reflect the new uninstalled test package location. Closes #1329
…move Update the pytest target in continue_config.yml from xcp_d to test (the tests directory moved from xcp_d/tests/ to test/ in the src-layout restructure). Update conftest.py default paths from the old installed- package location to the CircleCI source-tree location (/tmp/src/xcp_d).
Extract mock_config, get_nodes, chdir, modified_environ, get_cpu_count, and update_resources from test/tests.py and test/utils.py into a new src/xcp_d/_testing.py module. This eliminates imports from the test/ package in both test files and workflow docstrings, and makes these utilities available as part of the installed package under xcp_d._testing. Delete test/tests.py now that all its content has moved.
Move download_test_data, get_test_data_path, check_generated_files, check_affines, run_command, reorder_expected_outputs, and list_files from test/utils.py into src/xcp_d/_testing.py. Delete test/utils.py. Update get_test_data_path to compute test/data/ relative to the new location of _testing.py (src/xcp_d/ -> up 2 levels -> test/data/).
Replace hardcoded /tmp/src/xcp_d paths with a dynamically computed default so local runs find test/data/test_data/ at the project root rather than a CircleCI-only path.
Avoids a ModuleNotFoundError when conftest.py is loaded in a CI environment where the installed xcp_d predates _testing.py.
With src on pythonpath, pytest finds xcp_d from src/xcp_d/ rather than the installed package, making xcp_d._testing available even when the installed package predates the module.
Not needed: pytest's package import mode adds the project root to sys.path automatically (test/__init__.py is present), and xcp_d._testing is part of the installed package once the Docker image is rebuilt.
=== Do not change lines below ===
{
"chain": [],
"cmd": "bash -lc 'if pixi lock --check; then echo '\"'\"'Lockfile up to date'\"'\"'; else pixi lock; fi'",
"exit": 0,
"extra_inputs": [],
"inputs": [
"pixi.lock",
"pyproject.toml"
],
"outputs": [
"pixi.lock"
],
"pwd": "."
}
^^^ Do not change lines above ^^^
When _testing.py is installed, __file__ points to site-packages, not the source tree. test/data/ is not installed with the package, so the path must be computed from the working directory, which pytest always sets to the project root via testpaths.
get_test_data_path() cannot live in the installed package because test/data/ is source-tree-only infrastructure. Any __file__- or cwd- based computation in an installed module is fragile when the module is loaded from site-packages in a Docker container. Fix: expose test/data/ as a test_data_path pytest fixture in conftest.py, using Path(__file__) which is always the source-tree path since conftest is discovered and loaded from the filesystem (never from site-packages). - Remove get_test_data_path() from src/xcp_d/_testing.py - Add test_data_path session fixture to test/conftest.py - Thread test_data_path into all integration test functions and _run_and_generate in test/test_cli.py - Make download_test_data() require data_dir explicitly (no default) - Make reorder_expected_outputs() accept test_data_path as a parameter
When the package is installed to site-packages, coverage records paths like */site-packages/xcp_d/. The coverage.paths mapping tells combine these are equivalent to src/xcp_d/ in the source tree.
=== Do not change lines below ===
{
"chain": [],
"cmd": "bash -lc 'if pixi lock --check; then echo '\"'\"'Lockfile up to date'\"'\"'; else pixi lock; fi'",
"exit": 0,
"extra_inputs": [],
"inputs": [
"pixi.lock",
"pyproject.toml"
],
"outputs": [
"pixi.lock"
],
"pwd": "."
}
^^^ Do not change lines above ^^^
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.
Closes #1329.
Changes proposed in this pull request