AllenCell / AllenCell/allencell-segmenter-ml

Use TaskExecutor instead of doWork for long-running tasks

Đang mở
#452 6 bình luận 0 reaction 3 người được giao Được @yrkim98 nhận Xem trên GitHub
refactor
Ngôn ngữ chính
Python
Star
5
Fork
3
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**General idea**: use napari threads + our wrapper (TaskExecutor) + service classes instead of custom multi-threading solutions.

**Problem**: training and prediction both rely on `doWork` and `startLongRunningTaskWithProgressBar`, which are methods of the view superclass.

**Solution sketch**: (this is for training, but same idea can be applied to prediction)
1. introduce model state `training_in_progress` + signal `training_in_progress_toggled`
2. upon user clicking 'start training' set `training_in_progress` to `True` in the model
3. `training_in_progress_toggled` signal will emit `True`, view listener will then display progress bar, service listener will spin up training + fs event handlers
4. Instead of handling progress changes in `progress tracker`, just track those variables directly in the model, then the view can listen for changes to them and update the progress dialog accordingly
5. When service is done training, sets `training_in_progress` to `False` in the model
6. `training_in_progress_toggled` signal will emit `False`, causing the view to hide the progress dialog.

**Cool side effects**:
- can actually test the behavior of the training progress bar without starting any long-running processes or going crazy with mocks
- helps to standardize multi-threading strategy for the repository
- gets rid of the `View` superclass, which I'm not a fan of b/c it requires metaclass configuration which is a deep topic with potential pitfalls
- we could easily track loss in model state, which would mean we could get rid of some code I wrote that I don't like bc it reads from the FS on the main thread (this is related to showing loss at the end of training)

**Not-so-cool side effects**:
- (already large) model classes will grow larger
- probably a sizable refactor

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.