Skip to content

Commit 4404b9a

Browse files
committed
Reuse anatomical outputs from rbc-all in sequential test
The sequential test now copies anat derivatives from the rbc-all run instead of re-running brain extraction and registration, saving ~30-40 min of CI time. The disk round-trip handoff between functional, metrics, and QC stages is still fully tested.
1 parent 5167f70 commit 4404b9a

1 file changed

Lines changed: 31 additions & 13 deletions

File tree

tests/integration/test_all.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""Integration test for ``rbc all`` pipeline stage handoff.
22
3-
Runs the full pipeline via ``rbc all`` (in-memory handoff) and via the four
4-
individual subcommands in sequence (disk round-trip), then verifies that both
5-
approaches complete without errors, produce key derivative files, and yield
6-
identical outputs.
3+
Runs the full pipeline via ``rbc all`` (in-memory handoff) and via the
4+
individual subcommands in sequence (disk round-trip), then verifies that
5+
both approaches complete without errors, produce key derivative files,
6+
and yield identical outputs.
7+
8+
The sequential run reuses anatomical outputs from the ``rbc all`` run to
9+
avoid running brain extraction and registration twice.
710
"""
811

912
from __future__ import annotations
@@ -92,25 +95,40 @@ def all_output(tmp_path_factory: pytest.TempPathFactory, _runner: str) -> Path:
9295

9396

9497
@pytest.fixture(scope="session")
95-
def sequential_output(tmp_path_factory: pytest.TempPathFactory, _runner: str) -> Path:
96-
"""Run the four individual subcommands in order and return the output dir."""
98+
def sequential_output(
99+
tmp_path_factory: pytest.TempPathFactory,
100+
_runner: str,
101+
all_output: Path,
102+
) -> Path:
103+
"""Run functional/metrics/qc using anat outputs from ``rbc all``.
104+
105+
Copies the anatomical derivatives produced by the ``all_output``
106+
fixture so that only the functional, metrics, and QC stages run,
107+
saving ~30-40 min of redundant brain extraction and registration.
108+
"""
97109
out = tmp_path_factory.mktemp("sequential") / "derivatives"
98110
out.mkdir()
99111

112+
# Seed with anatomical outputs + dataset_description from rbc all
113+
anat_src = all_output / f"sub-{_SUB}" / "anat"
114+
anat_dst = out / f"sub-{_SUB}" / "anat"
115+
shutil.copytree(anat_src, anat_dst)
116+
shutil.copy2(
117+
all_output / "dataset_description.json",
118+
out / "dataset_description.json",
119+
)
120+
100121
runner_args = ["--runner", _runner, *_COMMON_ARGS]
101122
raw = str(_TEST_DATASET)
102123
deriv = str(out)
103124

104-
# 1. anatomical (raw BIDS only)
105-
_run_rbc(["anatomical", raw, "-o", deriv, *runner_args])
106-
107-
# 2. functional (raw BIDS + anat derivatives)
125+
# functional (raw BIDS + anat derivatives)
108126
_run_rbc(["functional", raw, deriv, "-o", deriv, *runner_args])
109127

110-
# 3. metrics (raw BIDS + derivatives from previous stages)
128+
# metrics (derivatives from previous stages)
111129
_run_rbc(["metrics", raw, deriv, "-o", deriv, *runner_args])
112130

113-
# 4. qc (raw BIDS + derivatives from previous stages)
131+
# qc (derivatives from previous stages)
114132
_run_rbc(["qc", raw, deriv, "-o", deriv, *runner_args])
115133

116134
return out
@@ -179,7 +197,7 @@ def test_rbc_all_produces_derivatives(all_output: Path) -> None:
179197

180198
@pytest.mark.slow
181199
def test_sequential_produces_derivatives(sequential_output: Path) -> None:
182-
"""Running anatomical/functional/metrics/qc individually produces the same files."""
200+
"""Running functional/metrics/qc individually produces the same files."""
183201
_assert_derivatives_exist(sequential_output)
184202

185203

0 commit comments

Comments
 (0)