Skip to content

Conversation

@shaneahmed
Copy link
Member

Merge ⚑ Make WSIPatchDataset Pickleable to Support Windows Multithreading (#946) avoiding conflicts.

measty and others added 3 commits August 8, 2025 17:33
…947)

This PR makes the WSIPatchDataset class picklable by delaying the creation of the reader object until the first call to `__getitem__`. This enables the use of multiple loader workers on Windows without errors and provides significant performance improvements.

- Delays reader object instantiation to the first `__getitem__` call instead of during initialization
- Extracts reader creation logic into a separate `_get_reader` method
- Stores image path and mode as instance variables for lazy initialization

Speedup for the WSI prediction cell of the patch_prediction example notebook: 
2min 48 sec with 0 loader workers -> 1min 13 sec with 4 workers.

Note: this PR doesn't have any effect for Linux as the multi-threading already works fine there because Linux multithreading doesn't require things to be pickleable
# Conflicts:
#	tiatoolbox/models/dataset/classification.py
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Aug 8, 2025
@shaneahmed shaneahmed self-assigned this Aug 8, 2025
@shaneahmed shaneahmed added the enhancement New feature or request label Aug 8, 2025
@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 91.77%. Comparing base (616fb84) to head (6d679d0).
⚠️ Report is 29 commits behind head on dev-define-engines-abc.

Additional details and impacted files
@@                   Coverage Diff                   @@
##           dev-define-engines-abc     #948   +/-   ##
=======================================================
  Coverage                   91.77%   91.77%           
=======================================================
  Files                          73       73           
  Lines                        9345     9354    +9     
  Branches                     1222     1224    +2     
=======================================================
+ Hits                         8576     8585    +9     
  Misses                        756      756           
  Partials                       13       13           

β˜” View full report in Codecov by Sentry.
πŸ“’ 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 merged commit 3c91874 into dev-define-engines-abc Aug 11, 2025
15 checks passed
@shaneahmed shaneahmed deleted the dev-update-patchdataset-reader branch August 11, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants