Skip to content

Add StopPredictionCallback to lightning callbacks#756

Merged
jdeschamps merged 8 commits intomainfrom
ds/NGC-move-StopPredictionCallback
Feb 10, 2026
Merged

Add StopPredictionCallback to lightning callbacks#756
jdeschamps merged 8 commits intomainfrom
ds/NGC-move-StopPredictionCallback

Conversation

@diyasrivas
Copy link
Copy Markdown
Member

@diyasrivas diyasrivas commented Feb 6, 2026

Description

Note

tldr: AddedStopPredictionCallback to CAREamics lightning callbacks for prediction stopping.

Overview - what changed?

This PR moves the prediction stopping functionality from careamics-napari to the main CAREamics library. The callback now accepts a generic Callable[[], bool] condition instead of UI-specific state objects.

Changes Made

New features or files

  • StopPredictionCallback class in src/careamics/lightning/callbacks/stop_prediction_callback.py
  • PredictionStoppedException exception for signaling prediction interruption
  • Test in tests/lightning/callbacks/test_stop_prediction_callback.py

Modified features or files

  • src/careamics/lightning/callbacks/__init__.py - added new exports
  • src/careamics/lightning/__init__.py - exposed the callback

How has this been tested?

  • All tests pass (pytest tests/lightning/callbacks/ -v)
  • New test covers callback initialization, stopping behavior, and stateful conditions
  • Verified imports work correctly: from careamics.lightning.callbacks import StopPredictionCallback, PredictionStoppedException

Related Issues


Please ensure your PR meets the following requirements:

  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Pre-commit passes
  • PR to the documentation exists (for bug fixes / features)

@diyasrivas
Copy link
Copy Markdown
Member Author

diyasrivas commented Feb 6, 2026

I tried to make a test tests/lightning/callbacks/test_stop_prediction_callback.py but I am not as experienced with this.. if you think it is unnecessary I can remove it.

@jdeschamps jdeschamps requested a review from a team February 9, 2026 09:14
Copy link
Copy Markdown
Member

@jdeschamps jdeschamps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, but indeed most tests need to go away. I made commit suggestions, you can just commit them if you agree.

Comment thread tests/lightning/callbacks/test_stop_prediction_callback.py Outdated
Comment thread tests/lightning/callbacks/test_stop_prediction_callback.py Outdated
Comment thread tests/lightning/callbacks/test_stop_prediction_callback.py Outdated
Comment thread tests/lightning/callbacks/test_stop_prediction_callback.py Outdated
Comment thread tests/lightning/callbacks/test_stop_prediction_callback.py Outdated
diyasrivas and others added 7 commits February 10, 2026 02:56
Co-authored-by: Joran Deschamps <6367888+jdeschamps@users.noreply.github.com>
Co-authored-by: Joran Deschamps <6367888+jdeschamps@users.noreply.github.com>
Co-authored-by: Joran Deschamps <6367888+jdeschamps@users.noreply.github.com>
Co-authored-by: Joran Deschamps <6367888+jdeschamps@users.noreply.github.com>
Co-authored-by: Joran Deschamps <6367888+jdeschamps@users.noreply.github.com>
@jdeschamps jdeschamps merged commit 7d6ae5e into main Feb 10, 2026
13 checks passed
@jdeschamps jdeschamps deleted the ds/NGC-move-StopPredictionCallback branch February 10, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Next-Gen CAREamics: move stop prediction callback from caremics-ui to careamics

2 participants