Skip to content

fix(line_scan_worker): handle datasets without IndexRange#139

Merged
arjunrajlab merged 4 commits into
masterfrom
fix/line-scan-worker-missing-indexrange
Jun 23, 2026
Merged

fix(line_scan_worker): handle datasets without IndexRange#139
arjunrajlab merged 4 commits into
masterfrom
fix/line-scan-worker-missing-indexrange

Conversation

@arjunrajlab

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes KeyError: 'IndexRange' in line_scan_worker when running on a single-frame dataset (one channel, no Z/T/XY stacks) with All channels checked.
  • large_image omits the IndexRange key on tiles entirely for single-frame datasets — not just IndexC. Switched to tiles.get('IndexRange', {}).get('IndexC', 1) to default to one channel, matching the defensive pattern already used in workers/annotations/crop/entrypoint.py:116 and workers/annotations/registration/entrypoint.py:163.
  • Prior precedent: commit a2b1609 ("Fix bug if there's only one channel") fixed the same shape of bug in annotation_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:

File "/entrypoint.py", line 80, in compute
    channels = range(datasetClient.tiles['IndexRange']['IndexC'])
KeyError: 'IndexRange'

Test plan

  • Run line scan worker with All channels = true on a single-channel/single-frame dataset → no crash, one channel processed.
  • Run with All channels = true on a multi-channel dataset → still iterates over all channels (regression check).
  • Run with All channels = false on either → still uses the selected channel only.

🤖 Generated with Claude Code

arjunrajlab and others added 4 commits May 26, 2026 06:18
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
@arjunrajlab arjunrajlab merged commit 59bba78 into master Jun 23, 2026
1 check passed
@arjunrajlab arjunrajlab deleted the fix/line-scan-worker-missing-indexrange branch June 23, 2026 11:53
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.

1 participant