im_info: add DROPPABLE_KEYS + presets + remove_marked_intermediates (Slice 1 of #245)#250
Merged
Merged
Conversation
…Slice 1 of #245) Foundation for per-output intermediate retention. Adds module-level ``DROPPABLE_KEYS`` (the 14-key universe of toggleable outputs: 12 image-like intermediates + ``adjacency_maps`` + the special ``im_path``), three preset constants (``KEEP_EVERYTHING_PRESET``, ``MASKS_AND_CSVS_PRESET``, ``CSVS_ONLY_PRESET``), and a new method ``ImInfo.remove_marked_intermediates(drop_keys)`` that validates the input against ``DROPPABLE_KEYS`` and deletes only the marked files (silently skipping any that were never produced). Legacy ``ImInfo.remove_intermediates()`` is refactored into a one-line shim calling ``remove_marked_intermediates(drop_keys=DROPPABLE_KEYS)``; the two pre-existing pinned tests (``test_remove_intermediates_preserves_csv_files``, ``test_remove_intermediates_deletes_canonical_im_path``) continue to pass unchanged. 11 new tests in ``tests/test_verifier_iminfo.py`` (section H.1) pin: ``DROPPABLE_KEYS`` membership exact (no CSVs); each preset's membership; per-key drop semantics; empty drop set is a no-op; unknown / CSV keys raise ``AssertionError``; missing files are silently skipped; ``im_path`` resolves correctly; legacy shim matches the new method. ADR 0014 documents the API-shape decision (``frozenset[str]`` over a structured dataclass). Closes #246 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 12, 2026
aelefebv
added a commit
that referenced
this pull request
May 12, 2026
… Qt importorskip + wiki close-out (#245) (#254) CI fixes for the per-output retention slices (PRs #250-#253): 1. **Windows mmap-release** in ``ImInfo.remove_marked_intermediates``. The post-rewrite method tried to ``os.remove(im_path)`` while ``self.im`` still held the tifffile memmap, triggering ``PermissionError [WinError 32] The process cannot access the file because it is being used by another process`` on Windows CI. Fix: drop ``self.im`` (and ``gc.collect()``) at the start of the method — the existing pattern documented at ``_release_iminfo_memmap`` in ``test_verifier_iminfo.py``. Always-release is the cheapest and safest default; any pipeline intermediate could be memmap'd by a stage that's still alive in the process. Callers who use ``info.im`` after cleanup get ``None`` (correct — the file may be gone). 2. **Ubuntu headless Qt** ImportError on ``libEGL.so.1`` for ``test_napari_settings.py``. ``qtpy.QtWidgets`` transitively pulls Qt's display libs even for the dataclass-only tests (``SettingsConfig`` lives in the same module). Fix: module-level ``pytest.importorskip("qtpy.QtWidgets")`` so the entire file skips cleanly on systems without Qt's display libs. Tests pass normally where Qt loads. Phase 5 wiki close-out for PRD #245: - ``wiki/glossary.md`` — new ``DROPPABLE_KEYS`` entry pointing to [[decisions/0014-intermediates-policy-frozenset]]. - ``wiki/pipeline.md`` Gotchas — new bullet for the per-output cleanup mechanism: end-of-pipeline-only, only-on-success (inherits the existing "no try/except around stages" gotcha), ``cleanup_drop_keys`` kwarg surface. - ``wiki/im-info.md`` test-coverage line — updated to call out ``remove_marked_intermediates`` + ``DROPPABLE_KEYS`` / preset-constants alongside the legacy ``remove_intermediates`` shim. Test count bumped (~57 → ~68). - ``wiki/now.md`` — "Active work" cleared; "Recently shipped" entry summarizes the four-slice chain, the API surface, the failure semantics, the test count delta (715 → 748 non-perf), and the new ADR. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nellie.im_info:DROPPABLE_KEYS(the 14-key universe),KEEP_EVERYTHING_PRESET,MASKS_AND_CSVS_PRESET,CSVS_ONLY_PRESET.ImInfo.remove_marked_intermediates(drop_keys: frozenset[str])— validates againstDROPPABLE_KEYS, deletes only the marked files, silently skips missing ones.ImInfo.remove_intermediates()into a one-line shim calling the new method withDROPPABLE_KEYS. Both pre-existing pinned tests pass unchanged.tests/test_verifier_iminfo.py(section H.1) pin the contract.wiki/decisions/0014-intermediates-policy-frozenset.md.Closes #246. Foundation for Slices 2/3 of #245.
Test plan
uv run pytest tests/test_verifier_iminfo.py -q— 68 passed (was 57, 11 new)DROPPABLE_KEYSmembership matches_create_output_paths(every non-CSV key plusim_path)remove_intermediates()semantics preserved end-to-end🤖 Generated with Claude Code