Commit fd1faae
modularizing data package (#366)
* add planning roadmap
* docs: start milestone v1.1 Extract viscy-data
* docs: complete viscy-data project research
* docs: define milestone v1.1 requirements
* docs: create milestone v1.1 roadmap (4 phases)
* docs(06-package-scaffolding-and-foundation): create phase plan
* feat(06-01): create viscy-data package directory structure with pyproject.toml
- Add pyproject.toml with hatchling build, uv-dynamic-versioning, all base deps
- Declare optional dependency groups: triplet, livecell, mmap, all
- Add PEP 561 py.typed marker and tests/__init__.py
- Configure pattern-prefix for independent versioning
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(06-01): add type definitions and package init with re-exports
- Copy all type definitions from viscy/data/typing.py into _typing.py
- Add INDEX_COLUMNS from viscy/data/triplet.py for shared access
- Update typing_extensions.NotRequired to typing.NotRequired (Python >=3.11)
- Create __init__.py with full re-export of all public types
- Add README.md required by hatchling build
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(06-01): integrate viscy-data as workspace dependency in root pyproject.toml
- Add viscy-data to root dependencies list
- Register viscy-data as workspace source in [tool.uv.sources]
- Verified editable install and full import chain works
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(06-01): complete package scaffolding plan with summary and state update
- Add 06-01-SUMMARY.md documenting viscy-data package creation
- Update STATE.md with plan position, metrics, and decisions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(06-02): extract shared utility functions into _utils.py
- Extract _ensure_channel_list, _search_int_in_str, _collate_samples, _read_norm_meta from hcs.py
- Extract _scatter_channels, _gather_channels, _transform_channel_wise from triplet.py
- Update imports to use viscy_data._typing instead of viscy.data.typing
- Add __all__ listing all 7 utility functions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(06-02): complete utility module extraction plan
- Add 06-02-SUMMARY.md documenting utility extraction
- Update STATE.md: Phase 6 complete, progress 80%
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(phase-6): complete phase execution
* docs(07-code-migration): create phase plan
* feat(07-01): migrate select.py, distributed.py, segmentation.py to viscy-data
- Copy select.py with well/FOV filtering utilities (no internal viscy imports)
- Copy distributed.py with ShardedDistributedSampler (no internal viscy imports)
- Copy segmentation.py with viscy.data.typing -> viscy_data._typing import update
- Add missing docstrings to satisfy ruff D rules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-01): migrate hcs.py to viscy-data with utility import rewiring
- Copy HCSDataModule, SlidingWindowDataset, MaskTestDataset from main
- Replace viscy.data.typing imports with viscy_data._typing
- Remove 4 utility function definitions (now in _utils.py)
- Add import from viscy_data._utils for shared utilities
- Remove unused re and collate_meta_tensor imports
- Add missing docstrings for ruff D compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-01): migrate gpu_aug.py to viscy-data with dependency rewiring
- Copy GPUTransformDataModule, CachedOmeZarrDataset, CachedOmeZarrDataModule
- Rewire viscy.data.distributed -> viscy_data.distributed
- Rewire viscy.data.hcs utility imports -> viscy_data._utils
- Rewire viscy.data.select -> viscy_data.select
- Rewire viscy.data.typing -> viscy_data._typing
- Add missing docstrings for ruff D compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(07-01): complete core data module migration plan
- Add 07-01-SUMMARY.md documenting migration of 5 core modules
- Update STATE.md: phase 7 plan 1 of 4, decisions, metrics
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-03): migrate mmap_cache.py and ctmc_v1.py to viscy-data
- Rewire all imports from viscy.data to viscy_data prefix
- Add lazy import for tensordict with clear error message
- Add docstrings for ruff D compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-03): migrate livecell.py with lazy optional dependency imports
- Rewire imports from viscy.data to viscy_data prefix
- Add lazy imports for pycocotools, tifffile, torchvision
- Add import guards in LiveCellDataset and LiveCellTestDataset __init__
- Add docstrings for ruff D compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-03): migrate combined.py as-is with import rewiring
- Rewire viscy.data.distributed to viscy_data.distributed
- Rewire viscy.data.hcs._collate_samples to viscy_data._utils._collate_samples
- Preserve all 6 public classes without structural changes
- Add docstrings for ruff D compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-02): migrate cell_classification.py and cell_division_triplet.py
- Rewire imports from viscy.data to viscy_data prefix
- Add lazy import for pandas in cell_classification.py with clear error message
- Import _transform_channel_wise from viscy_data._utils (not triplet.py)
- Import INDEX_COLUMNS and AnnotationColumns from viscy_data._typing
- Add docstrings for ruff D compliance
* docs(07-03): complete optional dependency module migration plan
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(07-02): complete specialized module migration plan
- Add 07-02-SUMMARY.md documenting triplet, classification, and cell division module migration
- Update STATE.md with position, decisions, and metrics
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(07-04): add complete public API exports to viscy_data __init__.py
- Export all 45 public names (17 types, 2 utilities, 26 DataModules/Datasets/enums)
- Eager imports from all 13 modules (lazy guards handled internally by each module)
- Comprehensive __all__ list for IDE autocompletion and star-import support
- Ruff-sorted import ordering passes all lint checks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(07-04): complete public API exports plan - phase 7 fully done
- 07-04-SUMMARY.md documenting 45 public exports and full package verification
- STATE.md updated: phase 7 complete (4/4 plans), 12 total plans done
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(phase-7): complete code migration execution
* docs(08-test-migration-and-validation): create phase plan
* test(08-01): add conftest.py with HCS OME-Zarr fixtures for viscy-data
- Copy all 6 fixtures and _build_hcs helper from main branch conftest
- Replace legacy np.random.rand with np.random.default_rng (NPY002)
- No viscy import changes needed (only uses third-party libs)
- Provides preprocessed_hcs_dataset, small_hcs_dataset, tracks fixtures
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(08-02): complete smoke tests plan - phase 8 test migration done
- Created 08-02-SUMMARY.md documenting 52 smoke tests for viscy_data
- Updated STATE.md: phase 8 complete, 14 total plans executed
- DATA-TST-02 satisfied: import, __all__, optional dep messages, no legacy namespace
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(08-01): migrate test_hcs, test_triplet, test_select to viscy-data package
- Update imports from viscy.data.X to viscy_data
- Add BatchedCenterSpatialCropd to _utils.py (fixes batch dim handling)
- Fix triplet.py to use BatchedCenterSpatialCropd instead of CenterSpatialCropd
- Add tensorstore to test dependency group for triplet tests
- All 19 tests pass across 3 test files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(08-01): complete data test migration plan summary
- Create 08-01-SUMMARY.md documenting test migration and bug fixes
- Update STATE.md with BatchedCenterSpatialCropd decision revision
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(phase-8): complete test migration and validation
* docs(09-ci-integration): create phase plan
* feat(09-01): add viscy-data CI test jobs to GitHub Actions workflow
- Add test-data job with 3x3 matrix (3 OS x 3 Python) for viscy-data
- Add test-data-extras job (ubuntu-latest, Python 3.13) for extras validation
- Update check job needs to aggregate all test jobs: test, test-data, test-data-extras
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(09-01): complete CI integration plan
- Add 09-01-SUMMARY.md documenting viscy-data CI jobs
- Update STATE.md: phase 9 complete, v1.0 milestone complete
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs(phase-9): complete CI integration - milestone v1.1 done
* chore: complete v1.1 milestone — Extract viscy-data
Delivered: viscy-data package with 15 modules, 45 public exports,
optional dependency groups, 71 tests, and tiered CI.
Archives:
- milestones/v1.1-ROADMAP.md
- milestones/v1.1-REQUIREMENTS.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add missing pandas guards, restore conftest fixture, remove no-op CI filter
- Add `if pd is None` guard in ClassificationDataModule.setup() and
TripletDataModule._align_tracks_tables_with_positions() to raise
helpful ImportError instead of AttributeError when pandas is absent
- Fix ClassificationDataset error message to suggest `pip install pandas`
instead of `pip install 'viscy-data[triplet]'` (classification doesn't
need tensorstore)
- Restore `num_timepoints` parameter on `_build_hcs()` and add
`temporal_hcs_dataset` fixture from upstream commit 44b25b9
- Remove no-op `-m "not slow"` from test-data-extras CI job (no tests
use @pytest.mark.slow)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: add CLAUDE.md and update CONTRIBUTING.md
Add CLAUDE.md with project-specific instructions for Claude Code sessions.
Update CONTRIBUTING.md with ruff config centralization warning and numpy
docstring convention note. Synced from 71009b5.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: update uv.lock after rebase onto modular-viscy-staging
Regenerate lockfile to include viscy-data workspace dependencies
alongside viscy-models from the updated base branch.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* port changes from tests-zarrv3 branch
* ruff
* add additional test for the main dataloaders
* redundant tets 3. I think test 2 alreaady takes care of this.
* rename INDEX_COLUMNS
* remove unused LABEL classes
* fix(livecell): assign transform result and avoid mutable defaults
LiveCellTestDataset.__getitem__ discarded the return value of
self.transform(sample), so MONAI transforms had no effect.
Also replace mutable default lists in LiveCellDataModule.__init__
with None to prevent cross-instance state sharing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(cell_classification): raise ValueError, tighten val_fovs type, fix mutable default
- `raise (f"Unknown stage: {stage}")` raised a string instead of an
exception — use `ValueError`.
- `val_fovs: list[str] | None` was unconditionally indexed in
`setup()` — remove the `None` option since it's always required.
- `_subset(..., exclude_timepoints=[])` used a mutable default —
replace with `None`.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(gpu_aug): remove _filter_fit_fovs override so exclude_fovs is applied
CachedOmeZarrDataModule accepted exclude_fovs but its local
_filter_fit_fovs override only filtered wells, silently ignoring
excluded FOVs. Remove the override so the SelectWell mixin's
implementation (which filters both wells and FOVs) is used.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: rename select.py to _select.py (private module)
The module contains mostly private helpers (_filter_wells,
_filter_fovs) and a mixin dataclass (SelectWell). Renaming to
_select.py signals it is internal implementation detail.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: update package descriptions to "AI x Imaging" and CLAUDE.md
Update viscy-data description from "virtual staining microscopy"
to "AI x Imaging tasks" in README, pyproject.toml, and __init__.py.
Add viscy-models test example to CLAUDE.md.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(ctmc_v1): add missing prefetch_factor attribute
CTMCv1DataModule.__init__ did not set self.prefetch_factor, causing
an AttributeError when train_dataloader() or val_dataloader() was
called (inherited from GPUTransformDataModule). Set it to None.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add functional tests for ctmc, livecell, segmentation, classification
Add unit tests for the four data modules that previously only had
import smoke tests:
- test_ctmc_v1.py: setup, val subsample ratio, batch shape
- test_livecell.py: dataset/datamodule with mock TIFF + COCO data
- test_segmentation.py: paired pred/target datasets, z-slice
- test_cell_classification.py: annotation CSV, FOV split, timepoint exclusion
Also adds shared fixtures to conftest.py (single_channel_hcs_pair,
segmentation_hcs_pair, classification_hcs_dataset).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(livecell): add missing prefetch_factor; add dataloader iteration tests
Add prefetch_factor attribute to LiveCellDataModule (same fix as 97455eb
for CTMC). Add batch iteration + shape validation to classification and
livecell datamodule tests to match coverage patterns in test_hcs/test_triplet.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: delete leftover select.py after rename to _select.py
Commit 5b132f9 renamed select.py to _select.py but did not remove
the original file. Nothing imports from it.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use explicit positions[0] instead of leaked loop variable
CachedOmeZarrDataset and MmappedDataset both built self.channels
using the loop variable `position` after iterating, implicitly
depending on the last element. Use positions[0] to be explicit
and avoid UnboundLocalError on empty input.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(livecell): handle empty annotations and correct return type
Guard torch.stack against empty annotation lists in
LiveCellTestDataset.__getitem__ when load_labels=True, returning
properly shaped empty tensors instead of crashing.
Fix _parse_image_names return type annotation: list[Path] -> list[str].
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(segmentation): defer open_ome_zarr from __init__ to setup()
Store only paths in __init__ and open OME-Zarr stores in setup("test"),
consistent with other DataModules in the package and Lightning
conventions for resource lifecycle.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* print to logger
* refactor(triplet): remove BatchedCenterSpatialCropd from viscy-data
The transform already exists in viscy-transforms and viscy-data should
not depend on it. Replace the final crop with a shape validation check
in on_after_batch_transfer() and require initial_yx_patch_size to match
the desired output size.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(docs): convert Sphinx-style docstrings to numpy style in _utils.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(init): lazy-load submodules via PEP 562 __getattr__
Replace eager imports of all DataModule/Dataset submodules with
on-demand loading. Modules with optional dependencies (triplet,
livecell, mmap_cache) are no longer imported at `import viscy_data`
time. Add __init__.pyi stub for type-checker/IDE support.
Also split CI test-data job to run without --all-extras so the base
package is validated independently from optional dependencies.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: guard None dereferences and replace mutable default arguments
- cell_classification.py: guard _read_norm_meta() returning None
- hcs.py: guard MaskTestDataset with ground_truth_masks=None, add
missing array_key parameter, replace mutable default [] with None
- triplet.py, cell_division_triplet.py: replace mutable default []
with None for normalizations/augmentations parameters
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: correct return type annotations in _utils.py
_gather_channels and _transform_channel_wise return Tensor, not
list[Tensor].
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(combined): check stage before calling dm.setup()
Move the unsupported-stage guard to the top of setup() in
ConcatDataModule and CachedConcatDataModule so constituent data
modules are not set up for stages that will be rejected.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add tests for cell_division_triplet, mmap_cache, and HCS test stage
- test_cell_division_triplet.py: 11 smoke tests for dataset and datamodule
- test_mmap_cache.py: 5 smoke tests (skipped when tensordict missing)
- test_hcs.py: add setup("test") coverage for MaskTestDataset
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Eduardo Hirata-Miyasaki <edhiratam@gmail.com>
Co-authored-by: Alexandr Kalinin <alxndrkalinin@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 4ac3050 commit fd1faae
70 files changed
Lines changed: 13570 additions & 1682 deletions
File tree
- .github/workflows
- .planning
- milestones
- phases
- 06-package-scaffolding-and-foundation
- 07-code-migration
- 08-test-migration-and-validation
- 09-ci-integration
- research
- packages/viscy-data
- src/viscy_data
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
43 | 94 | | |
44 | 95 | | |
45 | 96 | | |
46 | | - | |
| 97 | + | |
47 | 98 | | |
48 | 99 | | |
49 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
3 | 18 | | |
4 | 19 | | |
5 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 9 | + | |
21 | 10 | | |
22 | 11 | | |
23 | 12 | | |
24 | 13 | | |
25 | 14 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 32 | + | |
42 | 33 | | |
43 | 34 | | |
44 | 35 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 36 | + | |
| 37 | + | |
49 | 38 | | |
50 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
51 | 42 | | |
52 | 43 | | |
53 | 44 | | |
54 | 45 | | |
55 | 46 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
67 | 54 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 55 | + | |
| 56 | + | |
72 | 57 | | |
73 | 58 | | |
74 | 59 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
82 | 66 | | |
83 | 67 | | |
84 | 68 | | |
| |||
88 | 72 | | |
89 | 73 | | |
90 | 74 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
95 | 82 | | |
96 | 83 | | |
97 | | - | |
| 84 | + | |
0 commit comments