Skip to content

Commit d9e0bfd

Browse files
authored
SC67 remove datasets dependency (#148)
* SC67 remove datasets dependency * SC_67 remove datasets depedency * SC_67 bump spatialdata * lock file * uv lock in cache * run tests * update registry * uv lock * sync locked before running tests * update matrix ci cd
1 parent 6f36f22 commit d9e0bfd

File tree

8 files changed

+2860
-2872
lines changed

8 files changed

+2860
-2872
lines changed

.github/workflows/run_tests.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,25 @@ jobs:
4343
with:
4444
filter: blob:none
4545
fetch-depth: 0
46+
4647
- name: Install uv
4748
uses: astral-sh/setup-uv@v5
4849
with:
49-
cache-dependency-glob: pyproject.toml
50-
- name: run tests using uv and pytest
50+
enable-cache: true
51+
cache-dependency-glob: |
52+
**/uv.lock
53+
**/pyproject.toml
54+
55+
- name: Sync env (locked, --lock makes it fail immediatelly if uv.lock out of date with pyproject.toml)
56+
run: uv sync --locked --extra dev --python ${{ matrix.python }}
57+
58+
- name: run tests using uv and pytest (locked, no sync)
5159
env:
5260
MPLBACKEND: agg
5361
PLATFORM: ${{ matrix.os }}
5462
DISPLAY: :42
55-
run: uv run --extra dev --python ${{ matrix.python }} pytest --cov harpy --cov-branch --cov-report=xml src/harpy/_tests
63+
run: uv run --no-sync pytest --cov harpy --cov-branch --cov-report=xml src/harpy/_tests
64+
5665
- name: Upload coverage
5766
uses: codecov/codecov-action@v4
5867
with:

benchmarks/benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setup_cache(self):
2929
"""Set up cache."""
3030
tile_repeat = (1, 10, 10) # will results in image of size tile_repeat * ( 22, 512, 512 )
3131

32-
sdata = hp.datasets.pixie_example(["fov0"])
32+
sdata = hp.datasets.pixie_example()
3333

3434
# create artificial large dataset
3535
arr = da.tile(sdata["raw_image_fov0"].data, tile_repeat)

docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb

Lines changed: 426 additions & 337 deletions
Large diffs are not rendered by default.

experiments/example_pixel_cell_clustering_ark.ipynb

Lines changed: 96 additions & 79 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers = [
2727
"Topic :: Software Development :: Testing"
2828
]
2929
dependencies = [
30-
"spatialdata>=0.2.6",
30+
"spatialdata>=0.4.0",
3131
"xarray>=2024.10.0",
3232
"dask>=2024.4.1,<=2024.11.2",
3333
"distributed",
@@ -43,7 +43,6 @@ dependencies = [
4343
"magicgui",
4444
"pyrootutils",
4545
"universal_pathlib",
46-
"datasets>=2.16.0",
4746
"crick",
4847
"lazy-loader>=0.4",
4948
# spatialdata_io depends on specific version of spatialdata: ImportError: cannot import name 'rasterize_bins_link_table_to_labels' from 'spatialdata' at readers/visium_hd.py", line 21
@@ -109,7 +108,6 @@ extra = [
109108
]
110109
# dev dependencies
111110
test = [
112-
"datasets",
113111
"opencv-python",
114112
"pytest",
115113
"pytest-cov",

src/harpy/datasets/pixie_example.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
import os
2+
13
import anndata as ad
24
import pandas as pd
3-
from spatialdata import SpatialData
5+
import pooch
6+
from spatialdata import SpatialData, read_zarr
7+
8+
from harpy.datasets import get_registry
9+
from harpy.utils.pylogger import get_pylogger
10+
11+
log = get_pylogger(__name__)
412

513

614
def _get_df(path):
@@ -29,8 +37,12 @@ def _get_adata(path, label_prefix="label_whole_"):
2937
return adata
3038

3139

32-
def pixie_example(fovs: list | None = None, with_pixel_output=True, with_cells_output=True) -> SpatialData:
40+
def pixie_example_datasets(fovs: list | None = None, with_pixel_output=True, with_cells_output=True) -> SpatialData:
3341
"""Example pixie dataset."""
42+
log.warning(
43+
"pixie_example_datasets() is deprecated: it relies on Hugging Face 'datasets' loading scripts, "
44+
"which were removed in datasets>=4.0.0. Use 'hp.datasets.pixie_example()' or pin 'datasets<4.0.0'."
45+
)
3446
import glob
3547
import os
3648
from pathlib import Path
@@ -125,5 +137,15 @@ def pixie_example(fovs: list | None = None, with_pixel_output=True, with_cells_o
125137
return sdata
126138

127139

140+
def pixie_example() -> SpatialData:
141+
"""Example pixie dataset, loaded from s3 bucket"""
142+
# Fetch and unzip the file
143+
registry = get_registry()
144+
unzip_path = registry.fetch("proteomics/pixie/sdata_pixie.zarr.zip", processor=pooch.Unzip())
145+
sdata = read_zarr(os.path.commonpath(unzip_path))
146+
sdata.path = None
147+
return sdata
148+
149+
128150
if __name__ == "__main__":
129-
pixie_example([0])
151+
pixie_example()

src/harpy/datasets/registry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def get_registry(path: str | Path | None = None) -> Pooch:
5151
"transcriptomics/xenium/Xenium_V1_humanLung_Cancer_FFPE/Xenium_V1_humanLung_Cancer_FFPE_he_image.ome.tif": "0348c3aeac4be3770fd3385a0cd99c3948b25b8d5e2d853add6c95e07a8baaf1",
5252
"transcriptomics/xenium/Xenium_V1_humanLung_Cancer_FFPE/Xenium_V1_humanLung_Cancer_FFPE_he_imagealignment.csv": "9b8e47bf81ca1aa447dc01a476ba6315cdf9ea66d7abb357d91e06ccf67735a7",
5353
"transcriptomics/xenium/Xenium_V1_humanLung_Cancer_FFPE/Xenium_V1_humanLung_Cancer_FFPE_outs.zip": "865c3805a959b51514555300df61328fc05055b939b9bece43522b8918314e1d",
54+
"proteomics/pixie/sdata_pixie.zarr.zip": "cdcb17e4e18165d5cfca2c07a899a0e5b19efea26c25826370ef2bf77ea6ad13",
5455
"proteomics/mibi_tof/sdata_multi_channel.zarr.zip": "930fd2574666b90d5d6660ad8b52d47afffc9522704b9e6fef39d11c9cfff06e",
5556
"proteomics/macsima/sdata_multi_channel.zarr.zip": "26187fe62b75c3411f948cbcea52abd24b318992509e768c2ed2f55ddcb99f28",
5657
"proteomics/macsima/tonsil_all.zarr.zip": "f3444332c9decb318c6eff03e719ee35df6d7399da2a04a17dbed5833bfd9ed7",

0 commit comments

Comments
 (0)