Pipeline migration plan¶
File-by-file plan for Candidate 4: extracting openptv2.pipeline and
openptv2.config from gui/. Decision record: docs/decisions/ADR-002-pipeline-and-context.md.
Goal¶
After this work, gui/ contains only widget modules, import openptv2.pipeline
does not load Traits, and every core → gui import is gone.
Target layout¶
src/openptv2/
pipeline/
__init__.py # exports run, loop, images, store, params
loop.py # py_sequence_loop + stages (py_start_proc_c, preprocess, detect, correspond, determine, trackcorr_init)
images.py # image_split, read_frame_images, _ParamView, _process_frame_worker, naming
store.py # _open_run_store, _ensure_target_output_writable, _resolve_exp_path
params.py # _resolve_experiment_params, _populate_*
config/
__init__.py # exports Experiment, ParameterManager, parameter_defaults, legacy_parameters
experiment.py # (moved from gui/)
parameter_manager.py
parameter_models.py
parameter_defaults.py
parameter_util.py
legacy_parameters.py
Commit 1 — add the new packages (copies), keep shims¶
- Create
pipeline/andconfig/by moving the bodies of the files above. - In
gui/ptv.py,gui/experiment.py,gui/parameter_*.py, replace the module body with a deprecated shim:
import warnings
def __getattr__(name):
warnings.warn("openptv2.gui.ptv is deprecated; use openptv2.pipeline", DeprecationWarning, stacklevel=2)
from openptv2 import pipeline as _m
return getattr(_m, name)
(Same pattern for experiment and parameter_*.)
- Add
openptv2.pipeline.run(exp)implementing the public entry point: resolves params via_resolve_experiment_params, runspy_sequence_loop, returns theRunStore(orNone). - Update
openptv2/__init__.pyto exportrunfrompipeline. - Tests: none expected to change; the shim keeps old imports working. Run full suite.
Commit 2 — switch internal imports¶
Rewrite these imports to the new paths (grouped, one PR per group is fine):
batch/pyptv_batch.py:from openptv2.gui.ptv import py_start_proc_c→openptv2.pipeline;from openptv2.gui.experiment import Experiment→openptv2.config.plugins/loader.py(lines 197, 297):from openptv2.gui import ptv as ptv_module→from openptv2 import pipeline as pipeline_module; passpipeline=pipeline_module.plugins/*.py:self.ptv.→self.pipeline.;self.ptv._open_run_store→self.pipeline._open_run_store;from openptv2.gui.ptv import _open_run_store→openptv2.pipeline.cli.py,autocalibration.py,holistic.py,recorrespond.py,trajectory_roi.py,tracking_probe.py:from openptv2.gui.ptv import .../openptv2.gui.ptv.X→openptv2.pipeline.algorithms/parameter_converters.py:from openptv2.gui.parameter_defaults import ...→openptv2.config.parameter_defaults.gui/pyptv_gui.py,gui/calibration_gui.py,gui/detection_gui.py, etc.:from openptv2.gui.ptv import .../ptv.X→openptv2.pipeline(these are widgets; they may keep importing pipeline).- Tests: update
tests/imports fromopenptv2.gui.ptv/openptv2.gui.experiment/openptv2.gui.parameter_*to the new paths. Target: zero imports of the shimmed modules insrc/andtests/.
Run full suite after each group.
Commit 3 — delete the originals¶
- Remove
gui/ptv.py,gui/experiment.py,gui/parameter_manager.py,gui/parameter_models.py,gui/parameter_defaults.py,gui/parameter_util.py,gui/legacy_parameters.py. - Remove the shims. The deprecated paths now raise
ModuleNotFoundError(or keep a tiny shim that raises a clear error pointing to the new module — recommended, for one more release). - Run full suite; fix any stragglers.
Verification¶
grep -rn "openptv2.gui.ptv\|openptv2.gui.experiment\|openptv2.gui.parameter" src/ tests/returns nothing (except the optional error-raising shim).python -c "import openptv2.pipeline; import openptv2.config; print('ok')"succeeds without importing traits (checksys.modules).openptv2-validateandopenptv2-batchstill work againsttest_data/test_cavity.- Add a contract test:
openptv2.gui.ptvis either absent or a shim (not the implementation).
Out of scope (separate tickets)¶
- Splitting
two_phase_tracking.py,pyptv_gui.py,autocalibration.py(Candidate 5). - Renaming
ptv→pipelinein plugin source is in scope (commit 2); renaming in user-facing docs is a follow-up. - The
TrackingContexttype (deferred; see ADR-002). - The single parameter schema (Candidate 2).