Skip to content

Add downloadable cells dataset via scverse-misc - #1149

Merged
LucaMarconato merged 16 commits into
mainfrom
add-cells-dataset
Aug 18, 2026
Merged

Add downloadable cells dataset via scverse-misc#1149
LucaMarconato merged 16 commits into
mainfrom
add-cells-dataset

Conversation

@timtreis

@timtreis timtreis commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

Exposes spatialdata.datasets.cells() alongside blobs/raccoon. It downloads the cells example dataset and loads it as a SpatialData object.

Dataset fetching is delegated to scverse-misc[datasets] (>=0.1.0, the first released version with the datasets feature). The registry shipped in src/spatialdata/datasets.yaml is parsed and fetched (downloaded, hash-verified, cached, loaded) at call time.

The actual download is exercised by test_cells_download, marked slow; the network-free test_cells_registry validates the shipped registry on every run.

timtreis and others added 2 commits June 22, 2026 10:54
Expose spatialdata.datasets.cells() alongside blobs/raccoon. It downloads
the cells example dataset and loads it as a SpatialData object, reusing the
scverse-misc datasets infrastructure (parse_registry + fetch with the
built-in spatialdata loader) rather than reimplementing a downloader.

- ship src/spatialdata/datasets.yaml registry (base_url + cells.zip sha256)
- add scverse-misc[datasets]>=0.0.10 dependency
- bump requires-python and ruff target to 3.12 (scverse-misc requires >=3.12)
- update CI matrix 3.11 -> 3.12
- docs + network-free registry test and a slow download test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timtreis
timtreis force-pushed the add-cells-dataset branch from 7d60be6 to c453909 Compare June 22, 2026 10:14
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.41%. Comparing base (2debe5f) to head (5451a53).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1149      +/-   ##
==========================================
+ Coverage   92.40%   92.41%   +0.01%     
==========================================
  Files          52       52              
  Lines        7858     7874      +16     
==========================================
+ Hits         7261     7277      +16     
  Misses        597      597              
Files with missing lines Coverage Δ
src/spatialdata/datasets.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

timtreis and others added 2 commits June 22, 2026 12:17
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timtreis
timtreis requested a review from LucaMarconato June 24, 2026 09:42
@LucaMarconato

LucaMarconato commented Jun 27, 2026

Copy link
Copy Markdown
Member

Didn't dive deep but this looks great. One important thing is missing, for each dataset we must list the license, and if the license requires attribution, we need to list that. Could you please add this?

timtreis and others added 2 commits July 6, 2026 15:04
The cells dataset is derived from the 10x Genomics Xenium Prime Cervical
Cancer FFPE sample, released under CC BY 4.0 (attribution required). Record
the license and attribution in the registry and document the expectation
that every dataset lists its license.
@timtreis

timtreis commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

@LucaMarconato added the license info 👌

@ajkswamy ajkswamy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, here are some suggestions for improvements:

  1. Please add a link to the associated PR in spatialdata-notebooks. Please also add a couple of lines describing the motivation for this PR along which what value it adds. I see the assocated PR in spatialdata-notebooks already has a couple of good lines in this direction.

Comment thread tests/datasets/test_datasets.py
Comment thread src/spatialdata/datasets.py
Comment thread src/spatialdata/datasets.py Outdated
import pooch
from scverse_misc.datasets import fetch, parse_registry

cache_dir = Path(path) if path is not None else Path(pooch.os_cache("spatialdata"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please also cover the "else" case here in tests.

Comment thread src/spatialdata/datasets.py Outdated
from scverse_misc.datasets import fetch, parse_registry

cache_dir = Path(path) if path is not None else Path(pooch.os_cache("spatialdata"))
registry = importlib.resources.files("spatialdata").joinpath("datasets.yaml")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see the three lines here are also used in the unit test for this function. Would it make sense to make this into a separate function. Maybe it will be reused if we add more datasets that use this pattern from spatialdata-misc

timtreis and others added 4 commits August 14, 2026 19:12
Extract _shipped_registry() and _cache_dir() helpers, shared between
cells() and the tests, removing the duplicated registry-parsing block.
_cache_dir() isolates the path-vs-default branch so both sides are
covered without a network call.

Describe the dataset contents in the docstring, and assert the concrete
element counts and shapes in test_cells_download.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parse_registry is untyped in the mypy env, so returning its result
directly tripped no-any-return; assign through annotated locals.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread tests/datasets/test_datasets.py Outdated
Comment on lines +55 to +57
@pytest.mark.slow
def test_cells_download(tmp_path) -> None:
# Downloads ~3 MB from the scverse example data bucket; opt out with `-m "not slow"`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than opt-out, I'll try turning this into opt-in and skip the test by default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done, made opt-in and opting in in the GitHub CI.

It's a small dataset here and not a big deal, but later when we test cloud support it's good that we differentiate between tests require a network and tests that do not.

LucaMarconato and others added 2 commits August 18, 2026 14:05
Rename the `slow` marker to `network` and flip it from opt-out
(`-m "not slow"`) to opt-in: tests marked `network` are skipped
unless `--run-network` is passed. Enable the flag in CI so
`test_cells_download` runs there, and document the `license_url`
convention for CC-BY-style datasets in datasets.yaml.
@LucaMarconato

Copy link
Copy Markdown
Member

Thanks both @timtreis and @ajkswamy. The new dataset downloader works great!

Made only some minor changes, auto-merging now.

@LucaMarconato
LucaMarconato enabled auto-merge (squash) August 18, 2026 12:06
@LucaMarconato
LucaMarconato merged commit f31ff45 into main Aug 18, 2026
10 checks passed
@LucaMarconato
LucaMarconato deleted the add-cells-dataset branch August 18, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants