Skip to content

🐛 Fix handling of None return_predictions in NucleusInstanceSegmentor CLI#1089

Open
Anannya30 wants to merge 5 commits into
TissueImageAnalytics:developfrom
Anannya30:fix/return-predictions-none-crash
Open

🐛 Fix handling of None return_predictions in NucleusInstanceSegmentor CLI#1089
Anannya30 wants to merge 5 commits into
TissueImageAnalytics:developfrom
Anannya30:fix/return-predictions-none-crash

Conversation

@Anannya30

Copy link
Copy Markdown

Problem :-
When running nucleus-instance-segmentor via CLI with AnnotationStore
output, it crashes with:
any(rp_ is True for rp_ in None)
TypeError: 'NoneType' is not iterable

This happens because CLI passes return_predictions=None but line 1972
expects a tuple.

Fix :-
Added or (False,) fallback:
return_predictions = kwargs.get("return_predictions") or (False,)

Testing :-
Verified fix works by running hovernet_fast-pannuke on a real WSI
region and successfully generating AnnotationStore output.

Anannya30 and others added 2 commits July 2, 2026 09:10
When CLI passes return_predictions=None, any() crashes on line 1972.
Added 'or (False,)' to safely default to (False,) when None is passed.

Fixes nucleus instance segmentor AnnotationStore output via CLI.
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (445530f) to head (3923aa9).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1089   +/-   ##
========================================
  Coverage    99.88%   99.88%           
========================================
  Files           85       85           
  Lines        11656    11657    +1     
  Branches      1531     1531           
========================================
+ Hits         11643    11644    +1     
  Misses           7        7           
  Partials         6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shaneahmed

shaneahmed commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thank you @Anannya30 . Please could you add a test to catch this error? Also as the bug is in CLI, this should be fixed in tiatoolbox/cli/nucleus_instance_segment.py

shaneahmed and others added 2 commits July 3, 2026 07:38
* 🔥 Remove `albumentations` dependencies

* 🔥 Remove `albumentations` dependencies

* ✅ Add tests for coverage

* ✅ Add tests for coverage

* 🐛 Fix deepsource error
…_cli_default_return_predictions to catch this regression.
@Anannya30

Copy link
Copy Markdown
Author

Hi @shaneahmed, thank you for the review!

I have made both changes you requested:

  1. Added the fix to tiatoolbox/cli/nucleus_instance_segment.py
    converting None to (False,) before passing to the engine.
  2. Added test_cli_default_return_predictions in
    tests/engines/test_nucleus_instance_segmentor.py to catch
    this regression.

Please review and let me know.

@shaneahmed shaneahmed changed the title fix: handle None return_predictions in NucleusInstanceSegmentor CLI 🐛 Fix handling of None return_predictions in NucleusInstanceSegmentor CLI Jul 3, 2026
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