Documented editable install breaks three unit-test suites: inference_models resolves as an empty namespace package from the repo root

Aperta Adatta ai principianti
#3,173 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Leggi le istruzioni di installazione in AGENTS.md riga 28 e .github/CONTRIBUTING.md riga 76. Aggiorna il comando per l’installazione editable di ./inference_models usando la modalità di compatibilità verificata e spiega perché è necessaria. Conferma che il comando documentato funziona dalla root del repository con le tre suite di pytest interessate indicate nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

AGENTS.md (line 28) and .github/CONTRIBUTING.md (line 76) tell contributors to set up a dev environment with

pip install -e ./inference_models -e ./workflows -e ./stream_vision -e .

and to run development commands from the repository root. Doing exactly that, these suites fail at collection:

python -m pytest tests/inference_cli/unit_tests
python -m pytest tests/workflows/unit_tests
python -m pytest tests/inference/unit_tests
ImportError while importing test module '.../tests/workflows/unit_tests/core_steps/common/query_language/operations/test_classification_results_operations.py'.
E   ImportError: cannot import name 'ClassificationPrediction' from 'inference_models' (unknown location)

tests/inference_sdk/unit_tests and (cd workflows && pytest tests/unit_tests tests/isolation) are fine.

Why

python -m pytest puts the repo root on sys.path. The repo root contains the inference_models/ project folder (pyproject, README, docs — no __init__.py), which shares its name with the inference_models package inside it. With the default setuptools editable install, the real package is served by an __editable___inference_models_*_finder.py meta-path hook, so the path-based finder sees only the project folder and resolves inference_models as an empty namespace package:

$ python -c "import inference_models as m; print(m.__path__, m.__file__)"
['/.../inference/inference_models'] None          # from repo root: wrong
$ cd /tmp && python -c "import inference_models as m; print(m.__file__)"
/.../inference/inference_models/inference_models/__init__.py   # elsewhere: right

CI is unaffected because the workflows use pip install --no-deps ./inference_models (non-editable), which installs a regular package into site-packages, and a regular package wins over a namespace portion.

workflows/ and stream_vision/ don't hit this because their package names (roboflow_workflows, streamvision) differ from their folder names.

Verified fix
pip install --config-settings editable_mode=compat -e ./inference_models

This installs via a plain .pth path entry, so the path-based finder finds the real package. After that, from the repo root:

Suite Before After
tests/inference_cli/unit_tests collection error 241 passed
tests/workflows/unit_tests collection error 1344 passed, 30 skipped
tests/inference/unit_tests collection error 5304 passed, 11 skipped

Also checked:

  • --config-settings editable_mode=strict works too (it installs a link tree via .pth), but new files then need a reinstall to be picked up, so compat is the friendlier default for development.
  • Using the pytest console script instead of python -m pytest does not help: pytest's default prepend import mode inserts the repo root anyway.
  • Installing non-editably (pip install ./inference_models, as CI does) also works, at the cost of reinstalling after every change.
Environment

macOS 15 (arm64), Python 3.12.13, pip via uv 0.10.8, setuptools default editable mode, main @ 9f67071d3.

Proposal

Happy to open a small PR. Options, smallest first:

  1. Update the install line in AGENTS.md and .github/CONTRIBUTING.md to use --config-settings editable_mode=compat for ./inference_models (or install it non-editably like CI does), with one sentence on why.
  2. Additionally, a guard in tests/conftest.py that fails fast with a clear message when inference_models.__file__ is None, so the next person gets "your editable install is shadowed" instead of a confusing ImportError.

Which would you prefer?

Lingua principale
Python
Stelle
2.5k
Fork
340
Merge medio
2g 11h
PR unite (30g)
92

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di roboflow/inference

Tutte le issue di roboflow/inference

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.