Skip to content

Add downloadable cells dataset via scverse-misc - #1149

Open
timtreis wants to merge 12 commits into
mainfrom
add-cells-dataset
Open

Add downloadable cells dataset via scverse-misc#1149
timtreis wants to merge 12 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.45%. Comparing base (4e19681) to head (b226ab9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1149      +/-   ##
==========================================
+ Coverage   92.44%   92.45%   +0.01%     
==========================================
  Files          51       51              
  Lines        7820     7836      +16     
==========================================
+ Hits         7229     7245      +16     
  Misses        591      591              
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.

def test_cells_download(tmp_path) -> None:
# Downloads ~3 MB from the scverse example data bucket; opt out with `-m "not slow"`.
sdata = cells(path=str(tmp_path))
assert isinstance(sdata, 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.

In case we want to write tests based on this dataset, it would be good if this test would verify some particular of the dataset similar to test_datasets above, like number of each type of elements expected, their shapes/sizes, etc.


def cells(path: str | None = None) -> SpatialData:
"""
Cells dataset.

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.

It would be good to include a brief description of what this dataset contains, to help developers adopt it.

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 3 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>
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