fix(line_scan_worker): handle datasets without IndexRange#139
Merged
Conversation
Single-frame datasets (one channel, no Z/T/XY stacks) omit the IndexRange key from tiles entirely, causing KeyError: 'IndexRange' when "All channels" was checked. Use .get() with defaults to fall back to a single channel, mirroring the pattern used in crop and registration workers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Required by pre-PR validation hook. The line_scan_worker entry itself is unchanged; this resyncs unrelated description drift from other workers that had been hand-edited. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds pytest-based tests that mock the worker, dataset, and annotation clients. Covers: - Single-frame datasets where tiles lacks IndexRange (the bug fix regression test — previously raised KeyError: 'IndexRange'). - IndexRange present but missing IndexC (defaults to one channel). - Multi-channel datasets iterate over all channels. - 'All channels' = false scans only the selected channel. - No-annotations early return. - Constant-valued image produces constant intensity profile. - Interface registers expected fields. Wires up a line_scan_worker_test service in docker-compose.yml so `./build_workers.sh --build-and-run-tests line_scan_worker` runs them. All 7 tests pass in the container. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolve conflicts from master's e06af20 "fix missing IndexRange fallbacks", which independently landed the same line_scan_worker entrypoint fix plus a test suite. - entrypoint.py: auto-merged (identical IndexRange .get() fallback on both sides; master also added the trailing newline). - REGISTRY.md: keep "Yes" in the Tests column — the worker now has tests. - tests/ (test_line_scan.py, __init__.py, Dockerfile_Test): keep this branch's versions, a strict superset of master's (7 tests vs 5, adding no-annotations and CSV-content coverage). Verified: ./build_workers.sh --build-and-run-tests line_scan_worker → 7 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgYphJWw3jgQoLx5MXz95h
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
KeyError: 'IndexRange'inline_scan_workerwhen running on a single-frame dataset (one channel, no Z/T/XY stacks) with All channels checked.IndexRangekey ontilesentirely for single-frame datasets — not justIndexC. Switched totiles.get('IndexRange', {}).get('IndexC', 1)to default to one channel, matching the defensive pattern already used inworkers/annotations/crop/entrypoint.py:116andworkers/annotations/registration/entrypoint.py:163.a2b1609("Fix bug if there's only one channel") fixed the same shape of bug inannotation_utilities/annotation_tools.py.The second commit is an unrelated REGISTRY.md regeneration to satisfy the pre-PR validator (the post-PR hook would do this automatically anyway).
Reproduction
User ran "All Line scan CSV" on a single-channel dataset and hit:
Test plan
🤖 Generated with Claude Code