Documented editable install breaks three unit-test suites: inference_models resolves as an empty namespace package from the repo root
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=strictworks too (it installs a link tree via.pth), but new files then need a reinstall to be picked up, socompatis the friendlier default for development.- Using the
pytestconsole script instead ofpython -m pytestdoes not help: pytest's defaultprependimport 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:
- Update the install line in
AGENTS.mdand.github/CONTRIBUTING.mdto use--config-settings editable_mode=compatfor./inference_models(or install it non-editably like CI does), with one sentence on why. - Additionally, a guard in
tests/conftest.pythat fails fast with a clear message wheninference_models.__file__ is None, so the next person gets "your editable install is shadowed" instead of a confusingImportError.
Which would you prefer?
Hi! I'd like to help fix this. Would you prefer a pytest config change (rootdir/pythonpath, so the root inference_models/ folder doesn't shadow the package) or a docs update? Happy to open a PR either way.
I reproduced the package-discovery issue on Ubuntu 24.04.4 LTS (x86_64) with Python 3.12.3 at commit 21059e9 (inference-models==0.39.8).
Using the same Python executable from both directories, I checked importlib.util.find_spec("inference_models").origin before and after reinstalling with --config-settings editable_mode=compat.
| Working directory | Default editable install | With editable_mode=compat |
|---|---|---|
| Repository root | None |
Package __init__.py |
/tmp |
Package __init__.py |
Package __init__.py |
In all three successful lookups, the resolved file was <repo>/inference_models/inference_models/__init__.py. Compatibility mode fixed package discovery from the repository root on my machine. I tested discovery only and skipped the full dependency install and pytest suites.