Repository navigation
Conversation
Replace the 65-entry registry_urls dict, previously scattered across 5 different GitLab commit SHAs, with a single templated base URL pointing at one GitLab Generic Package (CDN-backed, unlike raw commit blob URLs).
Previously, users without pooch installed got a hard ModuleNotFoundError when a data file needed downloading. Add a urllib-based downloader with sha256 verification as a fallback, so data still downloads without the optional pooch dependency. CI's WITHOUT_POOCH test leg still skips before touching the network, unchanged.
Standalone script (stdlib only: argparse, urllib, hashlib, concurrent.futures) for environments that can't or don't want scikit-image or pooch installed, e.g. Linux distribution packaging. Downloads and hash-verifies every CDN-hosted data file in parallel.
The 31 legacy example images/arrays were kept in the wheel so they'd work without a network connection. With the registry now pointing at a consolidated, CDN-backed package and a stdlib download fallback in place, they're fetched on demand instead, shrinking the wheel.
These doctests glob-matched files directly against the data package's source directory, which broke once legacy data files were removed from the wheel. Rather than depending on any specific file being available locally (bundled or fetched), generate synthetic sample images on the fly with binary_blobs() and write them to a temp directory instead.
The WITHOUT_POOCH CI leg only exercised the pre-existing pytest-skip guard, never the new urllib-based download path itself, leaving it without automated coverage. Test _default_data_url and _stdlib_download directly (via the httpserver fixture already used elsewhere in the suite), plus an end-to-end check that _fetch downloads through the stdlib path when pooch is unavailable.
|
| "data/green_palette.png": f"{_GITLAB_DATA_BASE_URL}/green_palette.png", | ||
| "data/horse.png": f"{_GITLAB_DATA_BASE_URL}/horse.png", |
There was a problem hiding this comment.
Personal-fork CDN config left in production code
_GITLAB_DATA_PROJECT and _GITLAB_DATA_PACKAGE resolve to a personal GitLab account (stevesilvester1073%2Fdata) and test package (scikit-image-data-steve-test). Every call to skimage.data.* that triggers a download will hit this personal namespace, which can be deleted, renamed, or made private at any time — causing silent failures for all users. The PR description and the comment above acknowledge this must be updated to the production values before merging, but the change is easy to miss during a rushed merge.
_default_data_url()'s fallback branch pointed at src/_skimage2/ for any registry entry without a registry_urls override. Every such entry is actually a test-only fixture committed under tests/skimage2/ instead, matching the base URL the pooch-based fetcher already uses for the same files (_create_image_fetcher(prefix='tests')).
|
Reviews (2): Last reviewed commit: "Fix incorrect fallback URL path for test..." | Re-trigger Greptile |
_skip_pytest_case_requiring_pooch() only fired on PYTEST_CURRENT_TEST, which pytest sets only while a specific test's call/setup/teardown phase is running -- not during collection. Several existing test files load datasets at module or class body scope (e.g. `IMG = data.astronaut()`), which runs during collection, so the guard silently no-opped and let a real network attempt through instead of skipping. This was previously masked because astronaut, camera, coins, moon, chelsea, phantom, and color were all legacy bundled files, so `_fetch()` returned via the local-file case before ever reaching the skip-or-download branch. Removing the legacy bundled files exposed the gap, breaking the Pyodide CI leg (which has no pooch by design and no working https support in its urllib) with raw ConnectionError/URLError collection errors across ~17 test files. Now also check PYTEST_VERSION (set for the whole pytest session, including collection, since pytest 8.0; scikit-image requires pytest>=9), so collection-time data fetches are properly skipped too.
|
Reviews (3): Last reviewed commit: "Fix pooch-skip guard missing module/clas..." | Re-trigger Greptile |
If scikit-image-data is installed, use its bundled copy of a file instead of downloading/caching it -- checked before the existing cache/legacy/download cases in _fetch. Add tests (skipped unless the package is installed) covering both that a bundled file is served without touching the download cache and that a non-bundled file still falls through to a normal download. Also add a CI job that installs the package from its GitLab fork and runs these tests.
|
Reviews (4): Last reviewed commit: "Prefer the optional scikit-image-data pa..." | Re-trigger Greptile |
_registry.py's registry_urls repeated each CDN-hosted filename twice (as the dict key's basename and again in the f-string value) across 65 entries. Replace it with a flat list of keys plus a comprehension that derives the URL from each key's basename, removing the duplication. In tools/download_data.py: replace exec()-based registry loading with an AST walk that only evaluates simple top-level assignments (immune to a future import statement breaking it), and guard the registry[key] lookup in main() against a KeyError if a registry_urls entry ever lacks a matching hash.
… extra
Without pooch, _fetch previously fell back to a stdlib urllib-based
downloader. Remove that fallback: _fetch now raises a clear
ModuleNotFoundError pointing at the 'data' extra (or pooch directly)
when a file isn't already cached, legacy-bundled, or provided by the
optional scikit-image-data package. The 'data' extra now installs both
pooch and scikit-image-data, so the common gallery datasets are
available with no download at all.
Also fix a latent bug in tools/generate_requirements.py: its
self-reference check (dep.startswith('scikit-image')) also matched the
literal dependency name 'scikit-image-data', crashing when trying to
parse it as a scikit-image[extra] self-reference.
These 18 files were never actually shipped in built wheels (meson.build never listed them in install_sources), so this only affects editable/dev installs, where _fetch's now-removed "legacy_data_dir" case picked them up directly from the source tree. Everything they backed remains fetchable via the GitLab CDN through the normal registry mechanism. Also update _fetchers.py's README.txt (copied into the download cache on first use) and internal naming/comments to drop remaining mentions of the legacy-bundled concept.
block.png, chessboard_GRAY_U8.npz, chessboard_RGB_U8.npy/.npz, multi.fits, and simple.fits have no references anywhere in the codebase (verified via repo-wide grep and git blame/log). Their last usages were removed in prior refactors: block.png by the 0.16 novice submodule removal, the chessboard .npy/.npz duplicates by the 0.4 OpenCV wrapper removal, and multi.fits/simple.fits by the 2020 pooch migration that gutted test_fits.py without deleting the data files.
A bare `pip install scikit-image` used to leave a subset of common datasets (astronaut, camera, coins, etc.) working out of the box via bundled files. Now that those are gone, every skimage.data call needs either scikit-image-data or pooch. Update README.md's top-level install line and INSTALL.rst's wording accordingly, instead of the previous "required to access all example datasets" phrasing, which implied partial access without them.
.binder/requirements.txt didn't include requirements/data.txt, so every gallery example's "Launch Binder" button hit the same ModuleNotFoundError skimage.data now raises without pooch/scikit-image-data installed. Also add a note to the gallery landing page (doc/examples/README.txt) pointing at `pip install scikit-image[data]`, since most examples load images via skimage.data and nothing on the page said so.
scikit-image-data isn't on PyPI yet, so a plain 'scikit-image-data' dependency doesn't resolve for anyone actually trying the 'data' extra right now. Pin it to the personal GitLab fork branch validating this migration instead, clearly marked to revert before release: a direct URL/VCS dependency makes a package unpublishable to PyPI. Also fix a latent bug in tools/generate_requirements.py's conda environment.yml generator: its pkgname extraction only split on '>'/'=', so a "name @ git+https://..." dependency was treated as one unrecognized package and would've landed directly under conda's `dependencies:` list -- which can't resolve a git URL at all. Split on '@'/whitespace too, and route scikit-image-data through the existing pip-only mechanism (same as docstub) so it lands under the `pip:` subsection instead.
Leave the pre-existing install-via-pip/install-via-conda anchor names and the auto-generated requirements header alone -- neither is prose introduced by this PR.
Resolves two conflicts: - src/_skimage2/data/_fetchers.py: upstream renamed _LEGACY_DATA_DIR to the public legacy_data_dir (now tracked by tests/skimage/test_migration.py and both data/__init__.pyi files). Kept this branch's simplified pooch-fallback logic (no more Case 2 legacy-file lookup) but restored that exact name. - src/_skimage2/io/collection.py: upstream's doctest-postprocessing work touched two docstrings to use data.legacy_data_dir, but this branch had already independently rewritten those same doctests to generate synthetic images on the fly. Kept this branch's version; verified via `pytest --doctest-modules`. Also fixes two tests (in both tests/skimage2/ and tests/skimage/, copies of each other) that started failing under the merged tree: TestImageCollection's fixture mixed brick.png/moon.png (bundled by scikit-image-data, now installed under site-packages) with color.png (still pooch-cached under ~/Library/Caches/...). ImageCollection sorts input files by full path, so the differing location prefixes silently reordered the fixture relative to what the tests assumed. Swapped color.png for chelsea.png, which is also bundled by scikit-image-data and has a different shape than brick.png, so all three fixture files now share one location family. Full tests/skimage2/ suite: 9733 passed, 4 skipped, 0 failed.
pyproject.toml: move pooch and scikit-image-data (temporarily pinned to the GitLab fork branch) from the optional 'data' extra into the main dependencies -- skimage1's data.astronaut() and friends no longer bundle any files in the wheel, so scikit-image-data is what actually backs them now, and pooch is needed for skimage2's new fetch() API. Keep the 'data' extra around as a currently-redundant no-op: it'll matter again once skimage1 is dropped and scikit-image-data can move back to being purely optional. Regenerate requirements/*.txt and environment.yml, and fix a latent bug in generate_requirements.py that left a dangling '# data' comment in environment.yml once its only entry became pip-only. _skimage2/data: add a public fetch(data_filename) that wraps the existing private _fetch(), for skimage2 callers who want the resolved path directly. Remove the old bare-name dataset functions (astronaut(), camera(), etc.) from _skimage2.data's public surface -- they're still defined in _fetchers.py unchanged, since skimage1's shim imports them directly from there, bypassing _skimage2.data. Add fetch_<name>() aliases for the ones bundled by scikit-image-data instead, following sklearn's fetch_*() naming convention (sklearn.datasets.fetch_lfw_people, etc.) to signal these may need network access. Update tests/skimage2/data/test_data.py accordingly. Update README.md/INSTALL.rst/doc/examples/README.txt/_skimage2/data README.txt to describe the new hard-dependency reality: a bare `pip install scikit-image` now works out of the box for skimage.data, with no separate extra needed. Still pending: renaming the ~236 call sites across ~70 files in src/_skimage2 and tests/skimage2 that use the old bare names internally as test/docstring fixtures, and the fetch_<name>() test matrix (with/without scikit-image-data installed).
Now that _skimage2.data no longer exposes the old bare-name dataset functions publicly (astronaut(), camera(), etc. -- replaced by fetch_<name>() in the previous commit), update every internal test/docstring usage across src/_skimage2 and tests/skimage2 to match. 80 files, ~236 call sites, three call patterns handled: - `data.name(` / `ski2.data.name(` / `_skimage2.data.name(` (module attribute access) -> same prefix + `fetch_name(`. - `from _skimage2.data import name` direct imports -> renamed import plus every bare `name(` call site in that file. - `getattr(data, name)()` dynamic dispatch in test_thresholding.py, where `name` came from a list of string literals -- renamed the literals directly, since this pattern has no static `data.name(` text to match. Also fixes a false-positive collision the initial pass introduced: `ax[i].text(` (a matplotlib Axes.text() call) was incorrectly renamed to `ax[i].fetch_text(` since `text` is also a dataset function name; caught by sweeping every fetch_<name>( occurrence for a legitimate prefix and confirmed by the full test suite. skimage1 is unaffected (its shim imports the underlying functions directly from _skimage2.data._fetchers, bypassing _skimage2.data's public surface). Full tests/skimage2/ suite: 9736 passed, 4 skipped (unrelated missing optional deps), 0 failed. Pre-commit clean.
- Every fetch_<name>() is exposed on _skimage2.data, and its old bare name is not (closing the loop on the earlier removal). - fetch_astronaut()/fetch_camera() return correct data whether or not scikit-image-data is installed, and the download cache is only written to in the latter case (falls through to pooch). - The public fetch() resolves to the same path the private _fetch() would for the same key. 75/75 tests pass in tests/skimage2/data/test_data.py, no cache pollution, pre-commit clean.
Replace the manual urllib/hashlib downloader with pooch.retrieve(), per the PR description's "depends only on pooch" requirement (pooch is now a normal scikit-image dependency, so this is no longer a zero-dependency fallback). _load_registry()'s AST-based parsing is unchanged -- still doesn't need scikit-image installed. Also fixes a real concurrency bug found while testing: pooch's own directory creation isn't safe against concurrent calls for the same path, causing intermittent FileExistsError under parallel downloads when multiple files shared a subdirectory (data/, restoration/). Fixed by pre-creating every needed subdirectory once, up front, before the thread pool starts. Verified end-to-end against the real GitLab CDN: fresh download (65/65), re-run correctly detects all as already-cached, --force re-downloads everything, and a corrupted local file is detected and re-fetched on its own.
|
Too many files changed for review. ( Bypass the limit by tagging |
- Strip the fetch_ prefix when adapting _skimage2 doctests for skimage (v1), since v1 keeps the old bare names (e.g. astronaut()) while v2 uses fetch_astronaut(). Fixes ~107 doctest failures across CI. - Fix ImageCollection/MultiImage doctests in _skimage2/io/collection.py: binary_blobs()'s v2 signature (shape, blob_size) is incompatible with v1's positional signature (length, blob_size_fraction, n_dim), so a shared doctest using it broke when adapted for v1. Replace with plain numpy-generated sample images, and add the missing `import os` (the v1 shim module doesn't import os itself, and doctest-adapted class docstrings run against the shim module's globals). - Skip test_fetch_public_wrapper_matches_internal_fetch on WASM, where pooch's fetcher is unavailable (_image_fetcher is None), matching the existing pattern used by test_download_all_with_pooch.
- Several tests in tests/skimage2/data/test_data.py monkeypatched _image_fetcher without guarding for it being None (pooch not installed), not just on WASM -- caught by the linux optimize-and-no-pooch CI job. Added a shared requires_pooch marker and applied it to all affected tests. - .circleci/config.yml's "doc" job and test-nightlies-on-main.yaml's "Build and install" step both run `pip install --no-build-isolation .` before installing requirements/default.txt. Since scikit-image-data is now a hard git+https dependency with its own (hatchling) build backend, resolving it under a blanket --no-build-isolation breaks with BackendUnavailable: hatchling was never installed. Add --no-deps so this step only builds scikit-image itself, matching its existing "Ensure build succeeds without runtime requirements" comment; runtime deps (including scikit-image-data, built with normal isolation) are installed by the following requirements/default.txt step regardless.
The canny() migration example used checkerboard(), which -- unlike camera()/astronaut() used in the other migration examples -- isn't part of scikit-image-data's curated bundle and always requires a pooch download. This broke doc/tools/run_migration_doctests.py (run unconditionally, with no pooch-availability awareness) on the optimize-and-no-pooch CI job now that data files are CDN-only rather than bundled in the repo. Switch to camera(), matching the other migration examples.
Code review of the fetch() API changes flagged that fetch()'s docstring still called scikit-image-data "optional" (it's a hard dependency now, correctly described a few lines away in _fetch()'s own docstring), download_all()'s docstring/error still called pooch an "optional dependency", and a comment still used the old bare-name example data.astronaut() instead of data.fetch_astronaut().
Once scikit-image-data is published to PyPI with a real wheel, pip won't need to build it from source at all, so --no-deps stops being necessary here (though it remains harmless either way).
Now that scikit-image-data is a hard dependency, every other test-linux-* job's normal wheel install already pulls it in and runs the full test_data.py suite against it, making this job's original purpose (proving the with-scikit-image-data path gets exercised at all) redundant. Keeping it for now since it's a fast (~1min) canary for the external git dependency while it's still an unpublished personal-fork pin.
… registry to CDN keys - _fetch() gains a SKIMAGE_TEST_OFFLINE env var check (skipping rather than downloading when set, under pytest), with download_all() exempted via a private _force_online bypass since it's an explicit request to download everything. - Add a local_data_path fixture (tests/skimage2/conftest.py and tests/skimage/conftest.py, backed by a plain helper in _shared/testing.py) that skips a test when a git-tracked local fixture file is missing, instead of failing with a raw FileNotFoundError -- relevant for downstream repackagers testing against an installed wheel that doesn't ship tests/. Wired into all 8 existing call sites across color/, restoration/, and registration/ tests. - Restrict _image_fetcher's registry to only the CDN-hosted keys, and remove the GitHub raw-URL base_url fallback entirely, so a fetch for a key with no CDN url fails with pooch's own clear registry error instead of silently falling back to GitHub. Added a canary test guarding against a local-only fixture going missing/corrupted in our own CI (which always has the full checkout, unlike a downstream wheel install).
Sweep of prose introduced by this PR (comments, docstrings, error messages) for consistency with the earlier "via" sweep. Leaves pre-existing content alone, e.g. INSTALL.rst's install-via-pip anchor name and numpydoc section-underline syntax.
Code review caught that the previous sweep commit missed several occurrences, mostly in test_data.py's own newly-added docstrings and comments, plus a couple of pre-existing ones in tools/download_data.py and tools/generate_requirements.py. Also removed a docstring's reference to an internal design doc, since that shouldn't be referenced from PR-visible content.
All 4 Windows CI jobs failed test_local_only_registry_files_are_present on the same file: color/ciede2000_test_data.txt is the only plain-text (non-binary) fixture among the local-only registry keys, and git's core.autocrlf normalizes its line endings to CRLF on checkout there, changing its hash without changing its actual content. Retry against the LF-normalized bytes before declaring a file missing/corrupted.
…ation.py upstream/main's copy of this file (both tests/skimage/ and tests/skimage2/) has always used CRLF line endings; the tests/skimage2/ copy in this branch didn't, so GitHub's PR diff rendered the whole file as changed instead of just the handful of lines this PR actually touches. tests/skimage/'s copy already matched upstream (untouched by this commit). Content is unaffected; verified via `diff --strip-trailing-cr` against upstream/main that only the real edits remain, and the tests still pass.
test_imagecollection_input documents that its images are "always available in the user's install regardless of the availability of pooch", but chessboard_GRAY.png and rocket.jpg are not part of scikit-image-data's bundled set, so they now need a download and the test has no pooch guard. Swap in camera.png and retina.jpg, which are bundled, keeping the original RGB PNG / grayscale PNG / JPEG mix. The has_pooch detection in the same file had an empty try block with no import, so it was unconditionally True and the skipif guards on the GIF tests never fired. Import pooch so the detection works.
The name points at src/_skimage2/data/, which no longer holds any data files now that the bundled copies are gone, so it only misleads in the new API. skimage1 keeps it: its shim imports the name straight from _skimage2.data._fetchers, bypassing _skimage2.data's public surface, which is the same route the bare-name dataset functions already take. The frozen skimage.data:legacy_data_dir entry in test_migration.py is unaffected. Its one remaining use is locating README.txt in _ensure_cache_dir.
Both docstrings said "newer datasets are no longer included as part of the package", implying the rest still were. None are now: the curated set comes from scikit-image-data and everything else is downloaded, so data_dir holds only what has been downloaded so far. Say that, and note that download_all copies the bundled images into data_dir too, which is what test_download_all_with_pooch already asserts. The skimage2 text points at scikit-image[data], since scikit-image-data becomes optional there once skimage1 is dropped. skimage1's says it is installed alongside scikit-image, which stays true for as long as skimage1 exists. getting_started.rst built a path into data_dir to load moon.png, which has not held since the pooch migration and is unrelated to this PR: bundled images resolve outside data_dir, so the file is absent until download_all runs. Nothing caught it because doc/ is not in pytest's testpaths and no CI job runs `make doctest`. Since the passage is about loading your own image from a path, write a temporary file and read that back instead.
|
Splitting this up so the reviewable half can land now. The The remaining half, removing the bundled data files and serving them from a GitLab CDN, is tracked in #8286 with a full implementation plan. It is blocked on releasing The branch behind this PR is preserved ( |
Continues the effort to move scikit-image's example datasets off this repo and onto a dedicated, CDN-backed store, following #7875 and #7876, and revives the removal proposed in #7878 for the current (post-Megamove) tree.
See also prior discussion in #3323, #4538, and #7470.
Overview
scikit-image-data) and a generic packages repository in the GitLab repo.src/tree: 56 files totaling about 15 MB. 54 are binary (images and arrays) with no meaningful line count in a diff; the other 2,lbpcascade_frontalface_opencv.xmlandmulti.fits, are text formatted and account for about 2,500 of the diff's roughly 3,200 total deletions.skimage1andskimage2diverge in how they source example data (details below), but both keep large, non-bundled datasets CDN-only and unchanged.skimage1
data.astronaut()and friends behave exactly as before from the caller's perspective.scikit-image-databecomes a hard dependency, and the curated images are loaded from that package.poochbecomes a hard dependency of the distribution (required forskimage2'sfetch()API, see below),skimage1users get it "for free" and can download additional, non-bundled datasets without installing anything extra.skimage2
fetch(), plussklearn-style wrappers likefetch_astronaut(), following the pattern ofsklearn.datasets.fetch_*(e.g.fetch_lfw_people).poochis a hard dependency, added specifically to enable downloads throughfetch().scikit-image-datais also a hard dependency for now:skimage1's bare-name functions need it directly, and both APIs share a single install. Adataextra is kept as a placeholder for whenskimage1is eventually dropped andscikit-image-datacan become optional again forskimage2alone.scikit-image-datainstalled, and with it explicitly removed fromsys.modulesto exercise the fully-optional code path.Packaging notes
n_sphere_series) stay in the sdist even afterskimage1is eventually dropped — these are inputs to computation, not example data, and shouldn't move to the CDN package.skimage1andskimage2, unchanged from current behavior.tools/download_data.pyprovides a standalone way to pre-populate a local cache of every CDN-hosted data file (e.g. for offline/air-gapped builds or Linux distro packaging). It depends only onpooch— no need forscikit-imageitself to be installed to run it.Why not jsDelivr?
It doesn't support GitLab as a source (open since 2018), and GitHub isn't a viable alternative host either: our largest file (237 MB) exceeds GitHub's 100 MB blob limit without Git LFS, which jsDelivr can't resolve anyway.
Rollout sequencing
Before this can be merged and the hard dependency taken on:
scikit-image-dataas its own package.scikit-image-dataonto conda-forge.I am currently using https://gitlab.com/scikit-image/data/-/merge_requests/26/ and a temporary package repository for testing.
AI tool usage
Developed with Claude Code (Claude Sonnet 4.5); I reviewed all changes and test results.
Release note (optional)