Skip to content

PP-3: split run.py into the run package (move only) - #109

Merged
guijacquemet merged 3 commits into
mainfrom
claude/pp-3-split-run
Nov 1, 2026
Merged

guijacquemet merged 3 commits into
mainfrom
claude/pp-3-split-run

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

This is PP-3 of the v0.4.0 plan (preprocessing-design-v0.4.md revision 4, §8; plan-structure audit §5). It only moves code: no behaviour change. Review it with git diff --color-moved.

It is stacked on PP-2 (#66), which is stacked on PP-0 (#65, based on main). Merge order: #65, #66, then this PR.

Summary

run.py (895 lines after PP-2) becomes the package morphobricks_preprocessing/run/:

  • preflight.py: Preflight, SamplePlane, preflight, sample_planes, _exclusion_issues, _normalise
  • pipeline.py: run_experiment
  • result.py: RunResult
  • reuse.py: _load_previous, _describe_histogram
  • rows.py: _read_file, _bin_count, _range_issues, _pixel_issues, _row_order
  • publish.py: _staged_outputs, _publish_outputs, _OutputRollbackError
  • __init__.py: keeps the module docstring and re-exports the public names, so from morphobricks_preprocessing.run import … and morphobricks_preprocessing.run_experiment work as before.

Other changes:

  • Layers: each new module declares its layer in pyproject.toml. result.py is pure, pipeline.py is orchestration, and the rest are io.
  • Tests: they now patch the submodule that uses a name, for example run.rows.iter_xyc_planes or run.pipeline.file_sha256, instead of run.<name>. No assertion changed.
  • tools/check.py --rename OLD=NEW: a new option that re-keys the baseline entries of moved code, so a move does not count as a new violation. It never adds or raises an entry, and --update-baseline then drops what the move removed.
  • AGENTS.md: the module map and the testing notes are updated.

Notes for review

  • run_experiment is still 300+ lines (complexity 73). Cutting it below 60 lines is PP-7's job.
  • Each new module is under 400 lines.

Tests

  • No new tests (moves only); every existing test passes unchanged in substance.
  • Full gate as CI (ruff check, ruff format --check, tools/check.py --rules, pytest with .[dev,notebook,zarr]):
    • Python 3.13 with zarr 3: 1339 passed, 1 skipped (running as root ignores file modes).
    • Python 3.11 with zarr 2.18: 1321 passed, 19 skipped (that root skip plus 18 OME-NGFF 0.5 tests that need zarr 3).

Generated by Claude Code

Spec revision 4, section 8 PP-3 (plan-structure audit, section 5). No
behaviour change: every function and class is moved as it was, reviewable
with git diff --color-moved.

- run/preflight.py: Preflight, SamplePlane, preflight, sample_planes,
  _exclusion_issues, _normalise.
- run/pipeline.py: run_experiment.
- run/result.py: RunResult.
- run/reuse.py: _load_previous, _describe_histogram.
- run/rows.py: _read_file, _bin_count, _range_issues, _pixel_issues,
  _row_order.
- run/publish.py: _staged_outputs, _publish_outputs,
  _OutputRollbackError.
- run/__init__.py keeps the module docstring and re-exports the public
  names, so `from morphobricks_preprocessing.run import ...` still works.

Tests now patch the submodule that uses a name: run.rows.iter_xyc_planes,
run.pipeline.file_sha256 and the like.

tools/check.py --rename OLD=NEW re-keys the baseline entries of moved code;
it never adds or raises one. Each new module has a declared layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
@guijacquemet
guijacquemet changed the base branch from claude/pp-2-removals to main November 1, 2026 17:21
The AGENTS.md testing note keeps PP-3's wording: spy on `run.rows.iter_xyc_planes`, the
submodule that uses the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a

Copy link
Copy Markdown
Contributor Author

Independent review: approved, no fix needed beyond the merge of main (3e60007). Status: everything below is verified, and merging is the only step left.

Move only, verified

  • I compared the ASTs of every top-level def, class and assignment in the old run.py (PP-2 head ecfc5af) with the run/ package. All 20 are identical, docstrings included. The only new item is __all__ in run/__init__.py.
  • git diff --color-moved=zebra --color-moved-ws=allow-indentation-change: every non-moved added line is an import, a module docstring or the re-export.
  • Baseline: the five function entries are re-keyed with the same sizes, and the run.py file entry drops.
  • Tests only change patch targets to the submodules (run.rows.iter_xyc_planes, run.pipeline.*, global os/shutil). No assertion changed.
  • Old import paths:
    • morphobricks_preprocessing.run still exports Preflight, RunResult, SamplePlane, preflight, run_experiment and sample_planes. That covers MorphoRelate's from morphobricks_preprocessing.run import Preflight, preflight, the only use in the other bricks.
    • Names that were only incidentally importable from the old module (e.g. OUTPUT_FILENAME, private helpers) are gone. Nothing in this repo or the bricks used them.
  • Logger names become morphobricks_preprocessing.run.<module>. The CLI and the notebook attach their handlers to the package logger, so nothing is lost.

Merge of main (3e60007): the one AGENTS.md conflict keeps PP-3's testing note (run.rows.iter_xyc_planes).

Gate on 3e60007: ruff check and format clean, --rules clean.

  • 3.13 with zarr 3.4.2: 1343 passed, 1 skipped (root ignores file modes).
  • 3.11 with zarr 2.18.7: 1325 passed, 19 skipped (that one plus 18 OME-NGFF 0.5 tests that need zarr 3).
  • CI is green on all 7 jobs.

Follow-up: --rename can re-key any baseline entry to any path. Shrink-only is enforced only against the code, so baseline diffs need a reviewer's eye, or a CI check against origin/main's baseline.


Generated by Claude Code

@guijacquemet
guijacquemet marked this pull request as ready for review November 1, 2026 17:26
@guijacquemet
guijacquemet merged commit c16e757 into main Nov 1, 2026
7 checks passed
@guijacquemet
guijacquemet deleted the claude/pp-3-split-run branch November 14, 2026 08:20
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.

2 participants