Skip to content

Pin preprocessing v0.7.0 and normalization v0.7.1; pass a stopped run's refusal on (#126); document D47 (#124) - #133

Merged
guijacquemet merged 3 commits into
mainfrom
claude/pin-preprocessing-0.7.0
Nov 17, 2026
Merged

guijacquemet merged 3 commits into
mainfrom
claude/pin-preprocessing-0.7.0

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

One commit per item, from main (de5b5ae, after #127, #130, #132).

Closes #126. Closes #124. Supersedes draft PR #128.

1. Pins (b928f59)

  • Preprocessing v0.7.0 (8865b72), both the core requirement and the zarr extra. It was v0.6.1.
  • Normalization v0.7.1 (fcfaeac). It was v0.7.0.
  • git+https://github.com/CellMigrationLab/morphobricks-normalization.git@v0.7.1 is exactly the requirement string in preprocessing v0.7.0's pyproject.toml (D-h). tests/test_dependency_pins.py passes, and direct_url.json shows both bricks installed from their tags.
  • setup.py, AGENTS.md, docs/normalization.md, docs/normalization_contract.md and a new [Unreleased] CHANGELOG section name the new tags.
  • The notebooks install CellPatcher by its own tag, so they are unchanged until the release.

What changes in preprocessing v0.7.0 and normalization v0.7.1, and what it meant for CellPatcher's tests:

  • A_SCOPE_INCOMPLETE now says "present in k of n images" (it said "acquisitions"). Four tests quoted the old wording and are updated: test_cell_mask_request.py, test_channel_ids.py, test_condition_repeat_tree.py and test_ngff_labels.py. docs/configuration_reference.md now quotes the new text.
  • Partial coverage now says "imaging units"; unreadable_planes messages are capped; v29 gives a single refusal. No CellPatcher test quoted these texts. v29 is covered by the new test_stopped_run.py.
  • Normalization writes -0.0 as 0.0. No golden changed: tests/fixtures/v062_parity/digests.json and tests/fixtures/shared_labeller/golden.json pass as they are, because no golden case writes a -0.0. Nothing was regenerated.

2. A stopped run's refusal passed on unchanged (39f8c53, reworked from #128)

On a folder where preprocessing stopped without writing a run (Spec v29, R_HETEROGENEOUS_LAYOUT_NOT_ENABLED), preprocessing's RunInputs.open raises RunStoppedError. open_run turns it into a PreprocessingCheckError (chained from it) that holds:

  1. first, an issue whose code is exc.code (RUN_FOLDER_STOPPED) and whose message is str(exc), exactly, with an empty action (no advice from CellPatcher);
  2. then exc.issues, unchanged and in order.

RunReportUnreadableError gives one issue with its own code (RUN_FOLDER_REPORT_UNREADABLE) and str(exc), with the report as its path.

This follows Spec ADR 0005, "Construction and propagation": nothing is reworded and no CellPatcher code is wrapped around RUN_FOLDER_STOPPED.

Changed from #128: #128 put a CellPatcher preprocessing_run_refused issue, worded by CellPatcher, after the stopped run's issues. That issue is gone. The error's own code and message come first instead.

CellPatcher never reads discovery_report.json: no reader is left in src, and a test fails if it is read.

Unchanged from #128:

  • A folder with neither a run nor a stopped run's report gives "give a written run, or run preprocessing first" (no "again").
  • A stale written run keeps its advice to run preprocessing again.

The only "run preprocessing again" text left is inside preprocessing's own RunStoppedError message: "Fix what the errors say and run preprocessing again." It is passed on verbatim, as the ADR requires. CellPatcher adds none.

tests/test_stopped_run.py covers:

  • v29 end to end through run_patching_condition_repeat_tree, with code and message compared as strings to the RunStoppedError that RunInputs.open raises, and the issues compared to the run's own errors;
  • a monkeypatched RunStoppedError, where the paths are not re-sorted and discovery_report.json is never read;
  • three unreadable reports, each checked equal to RunReportUnreadableError;
  • written, check and provisional reports;
  • a folder with no report;
  • a stale run;
  • a source scan for RUN_FOLDER_ literals and discovery_report.json.

docs/normalization.md (troubleshooting table) and the CHANGELOG describe it.

MorphoFeature #240, row A07, needs updating with this. The line that matches "no run_manifest.json" in CellPatcher's message will no longer match. The message is now preprocessing's RUN_FOLDER_STOPPED: ....

3. D47 kept and documented (da47ad4, #124)

Owner decision of 17 November 2026 for #124: keep D47 and document it.

  • docs/plan.md §13 records D47 with its reason: an in-memory array carries no representation, its values cannot tell a region from labels, and CellPatcher labels no mask (ADR 0005 BM2/BM4, P05). It also records the rejected alternative, a representation= argument.
  • docs/patching_modes.md gets a warning callout in Cell mode and a pitfall line: a 0/1 region in memory is one large patch, so pass instance labels (label_binary, or the recorded binary_to_instances conversion).
  • run_patching's docstring says the same.
  • No behaviour change. tests/test_cell_strategy.py::test_d47_an_in_memory_region_is_one_object_through_run_patching pins it.

Checks

Fresh venv, Python 3.13, .[test,zarr,notebook] plus CPU torch. Both bricks were installed from their tags (direct_url.json: v0.7.0 → 8865b72, v0.7.1 → fcfaeac). PYTEST_ADDOPTS was unset.

  • Full suite in two halves (41 test files each):
    • 955 passed, 0 skipped;
    • 2130 passed, 0 skipped;
    • 3085 passed in total.
  • python tools/check.py --rules (code rules and Ruff against the baseline): clean.
  • The pytest part of tools/check.py was run as the two halves above, not in one process.

Generated by Claude Code

Preprocessing v0.7.0 (8865b72; core and zarr extra; was v0.6.1) and
normalization v0.7.1 (fcfaeac; was v0.7.0), the requirement string
preprocessing v0.7.0's pyproject pins (owner decision D-h). setup.py,
AGENTS.md, docs/normalization.md, docs/normalization_contract.md and a
new [Unreleased] CHANGELOG entry name the tags.

Preprocessing v0.7.0 words the resolver's A_SCOPE_INCOMPLETE as "present
in k of n images" (was "acquisitions", its #321): the four tests that
quoted the old word, and docs/configuration_reference.md, now quote the
new text. No golden changes.

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

Reworks draft PR #128 onto the preprocessing v0.7.0 pin. On a folder
where preprocessing stopped without writing a run (Spec v29,
R_HETEROGENEOUS_LAYOUT_NOT_ENABLED), RunInputs.open raises
RunStoppedError; open_run's PreprocessingCheckError (chained from it) now
holds first an issue whose code and message are the error's own code
(RUN_FOLDER_STOPPED) and str(), with no action of CellPatcher's, then the
error's issues unchanged and in order. RunReportUnreadableError gives one
issue with its code (RUN_FOLDER_REPORT_UNREADABLE) and message, naming
the report. Spec ADR 0005, construction and propagation: no rewording,
no CellPatcher code around RUN_FOLDER_STOPPED (#128 added a
preprocessing_run_refused issue after the stopped run's issues; that is
gone). CellPatcher never reads discovery_report.json.

A folder with neither a run nor a stopped run's report says to give a
written run or run preprocessing first; a stale written run keeps its
re-run advice. tests/test_stopped_run.py (from #128, with string-equal
code and message checks, a guard that no discovery_report.json is read
and a source scan for RUN_FOLDER_ literals); docs/normalization.md and
the CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Owner decision of 17 November 2026 on #124: keep D47. In memory an
integer cell-mode mask is instance labels used as stored, so a 0/1
integer region is one object: an in-memory array carries no
representation and its values cannot tell a region from labels, and
CellPatcher labels no mask (Spec ADR 0005 BM2/BM4). A described file run
declares the representation and refuses a binary mask as objects unless
binary_mask_policy is set.

docs/plan.md §13 records D47 with its reason and the rejected
alternative; docs/patching_modes.md and run_patching's docstring warn that
a region in cell mode is one large patch and say to pass instance labels.
No behaviour change; tests/test_cell_strategy.py pins it through
run_patching.

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

@guijacquemet guijacquemet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review: MERGE

Reviewed head da47ad4 against base de5b5ae. I worked in a fresh clone with a fresh Python 3.13 venv and ran pip install --no-cache-dir -e .[test,zarr,notebook] plus CPU torch. The bricks installed at preprocessing 8865b72 (v0.7.0) and normalization fcfaeac (v0.7.1). I compared the code against preprocessing v0.7.0 and against MorphoBricks-Spec main 1167108.

1. Pins: OK

  • setup.py:22-23 and :67-68 (zarr extra) pin morphobricks-preprocessing @ git+https://github.com/CellMigrationLab/morphobricks-preprocessing@v0.7.0. setup.py:30-31 pins morphobricks-normalization @ git+https://github.com/CellMigrationLab/morphobricks-normalization.git@v0.7.1.
  • The normalization string is byte-identical to preprocessing v0.7.0 pyproject.toml:29, which also uses the .git@v0.7.1 spelling (:44 gives the histology variant). That satisfies D-h. v0.7.1 resolves to fcfaeac9c104…, and v0.7.0 resolves to 8865b7265e21….
  • Every other mention is updated: AGENTS.md, docs/normalization.md, docs/normalization_contract.md, docs/configuration_reference.md and the four test quotes ("acquisitions" → "images"). No environment.yaml or notebook install line carries a tag. The remaining v0.6.1 and normalization-v0.7.0 mentions are history only: the CHANGELOG, the version lists in normalization_contract, and the dated health snapshot in AGENTS.md.

2. #126 against ADR 0005 "Construction and propagation": OK

  • In run_open.py:215-243 (_refusal_issues), a RunStoppedError becomes error(exc.code, str(exc), [folder]) followed by *exc.issues. The code and message are taken straight from the exception and the action is empty. The issue objects are the exception's own tuple, passed on as-is: same objects, same order, and their paths are not re-sorted. RunReportUnreadableError is handled the same way, with [exc.path].
  • Preprocessing builds both texts itself in run_inputs_stopped.py (_stopped_text, _unreadable and the report-version branch of _refusal). CellPatcher formats neither, and its src has no "RUN_FOLDER_ literal and no discovery_report.json (confirmed by grep and by the source-scan test).
  • The cause is chained (raise … from exc, run_open.py:197). Nothing is read from the experiment before the refusal. open_file_run and validate_image_and_mask_folders call open_run before any fovs() or plane read, and preprocessing reads its report only when the folder has no manifest, before any pixel.
  • A written but stale run still goes through _refusal_issue, unchanged. This is covered by test_a_stale_run_still_advises_running_preprocessing_again.

3. Tests: OK

  • I reverted src to b928f59 and kept the new tests. tests/test_stopped_run.py then gives 9 failed, 2 passed. The two that pass are the stale-run test and the source scan, and both are expected to pass on old code too.
  • To check the D47 test, I added connected-component labelling inside CellSegmentationStrategy.generate_regions. test_d47_an_in_memory_region_is_one_object_through_run_patching then fails at test_cell_strategy.py:368. So the test does pin the behaviour: one patch, label 1, area 136.

4. Goldens: OK

  • The PR changes no file under tests/fixtures. test_v062_output_parity.py and test_shared_labeller.py pass with normalization v0.7.1 installed. Neither v062_parity/digests.json nor shared_labeller/golden.json contains -0.0.

5. Docs, CHANGELOG and CI: OK

  • The full suite, run in two halves, gives 955 + 2130 = 3085 passed, 0 skipped. python tools/check.py --rules (code rules and Ruff) is clean.
  • All 7 CI checks pass on da47ad4: pytest (test), (test,zarr), (test,zarr,notebook), pytest-torch, pytest-windows, rules and spec-pin.
  • The CHANGELOG and the new row in docs/normalization.md describe what the code does.

Non-blocking notes

  1. The action text changes for a folder with no run. A plain manifest-less folder with no stopped report keeps its code and message, preprocessing_run_refused / "holds no run_manifest.json". Its action now reads "give a written run … or run preprocessing first" (run_open.py:233-240). This is deliberate and documented in the CHANGELOG, but it is the one change for a folder that is not a stopped run. The same branch also catches CellPatcher's own "run_manifest.json changed while it was opened" when the manifest disappears mid-open. That is a rare edge, and the advice is still reasonable there.
  2. The public exception does not match the original byte for byte. Byte-equality holds at the issue level: issues[0].code and issues[0].message match the original. But PreprocessingCheckError has no .code, and its str() joins str(issue) for every issue, so the exception's str() is not the original message. That is how PreprocessingCheckError has always worked, and RUN_FOLDER_* codes are not among the codes ADR 0005 lists. If the owner wants the stricter "own type with code / str() equal" form, that belongs in a follow-up.
  3. The spy in test_the_issues_come_from_run_stopped_error_not_from_reading_the_report is narrow. It patches only Path.read_text; a read through read_bytes or open would get past it. The source-scan test covers this, so it is not a gap in practice.

Generated by Claude Code

@guijacquemet
guijacquemet merged commit 89c4e3d into main Nov 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants