Skip to content

fix(samplers): refuse shallow copies and reset open passes on copy (merge after 302) - #304

Draft
selmanozleyen wants to merge 2 commits into
scverse:mainfrom
selmanozleyen:feat/explicit-sampler-copy
Draft

selmanozleyen wants to merge 2 commits into
scverse:mainfrom
selmanozleyen:feat/explicit-sampler-copy

Conversation

@selmanozleyen

@selmanozleyen selmanozleyen commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes: #303

Sorry I couldn't do stacked PR's because I cant push branches upstream

disclaimer: opus 5.5 was used in writing this code

…ase instead of a subclass, since its batches mix classes and so break ClassSampler's one-class-per-batch contract. Seeded output of both samplers is unchanged.
…mber generator, and track open passes in a shared mixin that resets them when a sampler or Loader is deep-copied or pickled. A ClassSampler, DistributedSampler or Loader copied mid-pass no longer refuses mask changes or datasets, or miscounts its shard's batches.
@selmanozleyen selmanozleyen self-assigned this Nov 12, 2026
@selmanozleyen selmanozleyen added the skip-gpu-ci Whether gpu ci should be skipped label Nov 12, 2026
@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.72%. Comparing base (c8091f0) to head (ac44d6e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
+ Coverage   91.70%   91.72%   +0.01%     
==========================================
  Files          18       18              
  Lines        1519     1522       +3     
==========================================
+ Hits         1393     1396       +3     
  Misses        126      126              
Files with missing lines Coverage Δ
src/annbatch/abc/sampler.py 100.00% <100.00%> (ø)
src/annbatch/loader.py 87.76% <100.00%> (-0.12%) ⬇️
...nnbatch/samplers/_class_samplers/_class_sampler.py 100.00% <100.00%> (ø)
...amplers/_class_samplers/_weighted_class_sampler.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_distributed_sampler.py 98.33% <100.00%> (-0.03%) ⬇️
src/annbatch/utils.py 73.72% <100.00%> (+2.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@selmanozleyen selmanozleyen changed the title fix(samplers): refuse shallow copies and reset open passes on copy (merge after 302 is merged) fix(samplers): refuse shallow copies and reset open passes on copy (merge after 302) Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-ci Whether gpu ci should be skipped

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copying a sampler or Loader mid-pass leaves the copy stuck

1 participant