Skip to content

Only expect ml_datasets registry entries when ml_datasets is installed - #14092

Open
AsadullahMaliyawala wants to merge 1 commit into
explosion:masterfrom
AsadullahMaliyawala:fix/registry-test-optional-ml-datasets
Open

AsadullahMaliyawala wants to merge 1 commit into
explosion:masterfrom
AsadullahMaliyawala:fix/registry-test-optional-ml-datasets

Conversation

@AsadullahMaliyawala

Copy link
Copy Markdown

Description

Running the test suite against an installed spaCy (python -m pytest --pyargs spacy, as described in the README) fails in test_registry_entries when ml_datasets is not installed:

AssertionError: Registry 'readers' missing entries: ml_datasets.cmu_movies.v1, ml_datasets.dbpedia.v1, ml_datasets.imdb_sentiment.v1

registry_contents.json lists the three ml_datasets.* readers, but they are registered by the ml_datasets package through entry points. ml_datasets is only in requirements.txt (development), not in install_requires, so a plain pip install spacy (or a distro package, as in #13856 on NixOS) does not have them.

The test now only expects entries from optional entry-point packages when that package is importable (OPTIONAL_ENTRY_PREFIXES, currently just ml_datasets). With ml_datasets installed the check is unchanged. This follows how the rest of the suite treats optional dependencies (pytest.importorskip in conftest.py).

Fixes #13856

Reproduced with spaCy 3.8.20 (current master) on Python 3.12 without ml_datasets: test_registry_population.py 1 failed / 2 passed before, 3 passed after. ruff format --check clean on the file.

I used an AI coding assistant (Claude) while investigating this; I reproduced the failure and ran the tests myself.

Types of change

Test fix.

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

ml_datasets registers its readers through entry points and is a
development requirement, not an install requirement, so running the
test suite against an installed spaCy (python -m pytest --pyargs spacy)
without it failed test_registry_entries.

Fixes explosion#13856

This branch has not been deployed

No deployments
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.

test_registry_entries fails with published spacy models

1 participant