Skip to content

Pass a stopped run's refusal on, from RunStoppedError (waits for the preprocessing release) - #128

Closed
guijacquemet wants to merge 1 commit into
mainfrom
claude/stopped-run-refusal
Closed

guijacquemet wants to merge 1 commit into
mainfrom
claude/stopped-run-refusal

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Do not merge until the next morphobricks-preprocessing release (the first release that contains #324) is tagged and pinned here. Rebased onto main (54e200b, after #127 / aca2c6c) and reworked to use preprocessing's public API (#322, merged on preprocessing main in #324 at b24371a, not yet released).

Addresses #126.

What it does

On a folder where preprocessing stopped without writing a run (Spec v29, R_HETEROGENEOUS_LAYOUT_NOT_ENABLED), preprocessing's RunInputs.open raises RunStoppedError (RUN_FOLDER_STOPPED, preprocessing contract §9.1 "A stopped run"). open_run catches it and:

  • passes its issues on first, unchanged and in order (code, message, paths and suggested action; Spec ADR 0005 propagation);
  • then adds preprocessing_run_refused naming the folder ("holds no run_manifest.json", RUN_FOLDER_STOPPED). It gives no advice to run preprocessing again.

A report that preprocessing cannot read (RunReportUnreadableError) gives one issue, coded RUN_FOLDER_REPORT_UNREADABLE, that names the report (exc.path).

CellPatcher no longer reads discovery_report.json. The previous report reader (_stopped_run_issues) is deleted.

Unchanged:

  • a stale written run keeps its advice to run preprocessing again;
  • a folder with no run and no stopped run's report still says to give a written run or run preprocessing first.

Pin (TODO(tag), this draft only)

  • setup.py pins preprocessing to commit b24371abe0a728995f44b2f8f1dd6d36b4a4addc, both the core requirement and the zarr extra. Normalization stays at v0.7.0, which is what that commit pins.
  • tests/test_dependency_pins.py::test_preprocessing_is_pinned_to_a_release_tag_not_a_commit requires a tag, so on this branch only it also accepts that one commit (PREPROCESSING_MAIN_COMMIT).
  • Before merging, both go back to the release tag.

Tests (tests/test_stopped_run.py)

  • v29: preprocessing's R_HETEROGENEOUS_LAYOUT_NOT_ENABLED issue, and the other errors after it, are passed on equal to RunStoppedError.issues and in its order. The folder notice follows, and nothing says "run preprocessing again".
  • Monkeypatched RunStoppedError: the issues are passed on as given (paths not re-sorted). A junk discovery_report.json sits beside them and is never read.
  • Unreadable report (not JSON, report version 2, or "stopped" with no error): one issue, RUN_FOLDER_REPORT_UNREADABLE, naming the report.
  • Written, check or provisional report, and no report at all: the plain no-run refusal, unchanged.
  • Stale run: the re-run advice is unchanged.

Gate

  • python tools/check.py with PYTEST_ADDOPTS unset, Python 3.13: 2976 passed, 10 skipped (all 10 need torch, which is not installed). Code rules and Ruff are clean.

MorphoFeature #240 adversarial/ A07

Installed as its README says, with this branch installed last using --no-deps --force-reinstall.

  • With the suite's pin, preprocessing v0.6.1: A07 fails. CellPatcher raises ImportError (RunReportUnreadableError), because this branch needs preprocessing at b24371a or later.
  • With preprocessing b24371a installed in the suite's env:
    • A07's line 184, the suite's own direct RunInputs.open(...) match on "no run_manifest.json", now fails. Preprocessing's message is now RUN_FOLDER_STOPPED: ..., so that line needs updating in #240 when it raises preprocessing.
    • CellPatcher's line (186-187, "no run_manifest.json") passes. Its issues are R_HETEROGENEOUS_LAYOUT_NOT_ENABLED, inconsistent_mapping, then preprocessing_run_refused, with no "preprocessing again".

Before merge

  1. Preprocessing tags its next release, which contains #324.
  2. Pin that tag here (core and zarr) and remove PREPROCESSING_MAIN_COMMIT from the pin test.
  3. In MorphoFeature #240, raise preprocessing and update A07's line 184.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc

Copy link
Copy Markdown
Contributor Author

Preprocessing now has a public API for this: CellMigrationLab/morphobricks-preprocessing#324 (for #322). It is not merged yet; an independent review comes first.

What to switch to. Drop the discovery_report.json reader and catch the error raised by RunInputs.open:

from morphobricks_preprocessing import RunInputs, RunStoppedError, RunReportUnreadableError

try:
    inputs = RunInputs.open(run_folder)
except RunStoppedError as stopped:          # code == "RUN_FOLDER_STOPPED"
    for issue in stopped.issues:            # tuple[ValidationIssue, ...], the report's order
        issue.code, issue.message, issue.paths, issue.action   # exactly as the report records them
except RunReportUnreadableError as bad:     # code == "RUN_FOLDER_REPORT_UNREADABLE"; bad.path
    ...
  • RunStoppedError is raised only when the folder holds no run_manifest.json and the report is the final report of a run that stopped. It comes before any image or mask is read.
  • issues holds the error issues only. Re-serialised with the report's own serialiser, each one is byte-equal to the report's entry (tested on Spec v29, R_HETEROGENEOUS_LAYOUT_NOT_ENABLED).
  • Both errors are RunInputsError subclasses with code set, and both are picklable.
  • RunReportUnreadableError (it names the file) is raised for a report that is unreadable, of another version, of the wrong shape, or stopped with no error.
  • Unchanged:
    • a folder with no report, a check report, or a provisional report keeps the existing RunInputsError "holds no run_manifest.json";
    • a folder with a manifest opens as before, whatever its report says.

The contract is §9.1, "A stopped run".


Generated by Claude Code

…126)

On an output folder where preprocessing stopped on purpose without writing a
run (Spec v29: RGB units beside fluorescence units,
R_HETEROGENEOUS_LAYOUT_NOT_ENABLED), CellPatcher refused with
preprocessing_run_refused and advised running preprocessing again, which stops
the same way.

Preprocessing's RunInputs.open now raises RunStoppedError (RUN_FOLDER_STOPPED,
preprocessing #322, merged in #324) there. CellPatcher passes its issues on
first, unchanged and in order (code, message, paths, suggested action; Spec
ADR 0005, construction and propagation), then preprocessing_run_refused naming
the folder ("holds no run_manifest.json") with no re-run advice. A report
preprocessing cannot read (RunReportUnreadableError) is refused with its code,
RUN_FOLDER_REPORT_UNREADABLE, naming the report. CellPatcher reads no
discovery_report.json. A folder with no run and no stopped run's report says to
give a written run or run preprocessing first; a stale written run keeps the
advice to run preprocessing again.

TODO(tag): preprocessing (core and zarr extra) is pinned to its main commit
b24371abe0a728995f44b2f8f1dd6d36b4a4addc until its next release is tagged, and
test_preprocessing_is_pinned_to_a_release_tag_not_a_commit accepts that one
commit. Both go back to a tag before this is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
@guijacquemet
guijacquemet force-pushed the claude/stopped-run-refusal branch from ab3cbe3 to 04d761e Compare November 17, 2026 01:51
@guijacquemet guijacquemet changed the title Pass a stopped run's refusal on (waits for preprocessing #322) Pass a stopped run's refusal on, from RunStoppedError (waits for the preprocessing release) Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

I'm closing this draft because its work is now in #133, recreated on top of the preprocessing v0.7.0 / normalization v0.7.1 pin commit. I recreated it instead of pushing here: this branch was based on 54e200b and its single commit mixed the interim commit pin into the change. Updating it would have needed a rebase and a force-push.

Changes from this draft:

  • The pin is a release tag. b24371a and PREPROCESSING_MAIN_COMMIT are gone.
  • Spec ADR 0005 propagation is followed. The first issue now carries RunStoppedError's own code (RUN_FOLDER_STOPPED) and str(), exactly, with no CellPatcher advice. The stopped run's issues follow, unchanged and in order. The CellPatcher-worded preprocessing_run_refused issue that came after them here is removed.
  • RunReportUnreadableError is also passed on unchanged.
  • discovery_report.json is still never read.
  • The tests compare the code and message as strings. They also fail if the report is read, and scan src for RUN_FOLDER_ literals.

Generated by Claude Code

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