mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-24 11:31:17 +08:00
<!-- maintainer-current-main -->
## Maintainer latest-main checkpoint
Published `fb146c0663b30488da0a49cfb33624ee82862074` contains current
upstream main `e4a60ed72f6ef5b28569f8bfbe2163cfda32c948`. 22
dependency/Gemini tests and lock check passed. Earlier live behavior
proofs below retain their commit/platform scope; contributor runtime
logic is unchanged.
The common shard-2 failure was independently confirmed on main's hosted
job 127069149772 and locally (four failures, six passes): the Gemini
memory fixture mocked an unused body reader and provided no request
stream. The maintainer test-only follow-up now constructs a real
FastAPI/ASGI Request carrying JSON bytes and exercises the actual body
reader. All six test-function ASTs/assertions are unchanged, and all 10
parameterized Gemini cases pass. Touched-file Ruff/format and whitespace
checks pass. This fixes the inherited fixture instead of asking
contributors to run CI or weakening the memory/content assertions. Fresh
exact-head hosted qualification is requested. Nothing merged.
<!-- /maintainer-current-main -->
## Description
On Linux, installing `headroom-ai[all]` resolved PyTorch and NVIDIA CUDA
packages even for users who only needed the CLI/proxy profile. The
locked dependency graph included those packages through `ml`, `memory`,
`evals`, and `voice`.
This keeps those PyTorch-backed extras available for explicit
installation while removing them from `[all]`. Image support and the
other CLI/proxy dependencies remain included; dependency metadata cannot
detect installed GPU hardware.
Closes #3339
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)
## Changes Made
- Remove `ml`, `memory`, `evals`, and `voice` from the `[all]` extra
while keeping each separately installable.
- Retain `image` and the other default CLI/proxy capabilities.
- Update README and installation docs to describe the opt-in extras and
CUDA package implications.
- Add a dependency contract assertion for the `[all]` extra.
## Testing
- [ ] Unit tests pass (`pytest`)
- [ ] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [ ] New tests added for new functionality
- [x] Manual testing performed
### Test Output
```text
Focused dependency contract tests: 3 passed, 5 deselected.
Python 3.13 locked `uv export` exited 0; the fixed export omits torch, CUDA, NVIDIA, sentence-transformers, and datasets. The baseline export contained them.
`uv lock --check`, scoped Ruff check/format, and `git diff --check` exited 0.
The broader dependency test module had 3 passed and 5 import failures because `opentelemetry` is absent from the local environment.
```
## Real Behavior Proof
- Environment: Linux, Python 3.13, locked uv dependency resolution.
- Exact command / steps: `UV_PYTHON_DOWNLOADS=never uv export --python
3.13 --extra all --no-dev --locked --no-hashes --no-emit-project`.
- Observed result: exit 0; the resolved export no longer contains torch,
CUDA, NVIDIA, sentence-transformers, or datasets, all of which were
present in the baseline export.
- Not tested: a full environment install and GPU runtime behavior.
## Runtime Rollout Safety
- Rollout-managed feature(s): None.
- Minimum rollout channel: Stable package release.
- Stable/default behavior changed: Yes; `[all]` no longer installs the
four PyTorch-backed extras.
- Kill switch / disable path: Not applicable; install the desired extras
explicitly.
- Unsafe override required: No.
- Qualification impact: Users of those capabilities must add the
corresponding extras.
- Rollback path: Restore the extras to `[all]` and regenerate `uv.lock`.
## Review Readiness
- [x] I have performed a self-review
- [x] This PR is ready for human review
## Checklist
- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)
## Screenshots (if applicable)
Not applicable to this dependency-resolution change.
## Additional Notes
The `[all]` install profile intentionally no longer includes
PyTorch-backed optional capabilities; each remains available through its
named extra. The focused regression and locked resolver proof passed,
but the full dependency test module and a full install were not verified
locally.
## Maintainer integration qualification
Published head `3229690b613810d496f015cedd086ca1d7421843` includes
current upstream main `31dcaf41`. The merge preserves main's `lean`
dependency profile and deprecated `sandbox` alias alongside the
contributor's opt-in `[all]` policy. No optional-feature runtime logic
was changed.
- Reconciled the existing macOS dependency test with the declared
policy, retaining the transitive exclusion check and independently
verifying explicit `ml`/`voice` opt-ins on Intel macOS and Linux. All 12
tests across `tests/test_onnx_dependency_contract.py` and
`tests/test_optional_dependencies.py` pass on Windows/Python 3.12.13.
- Evaluation workflow installs now explicitly request `evals`, and the
model-allowed weekly job also requests `ml`, preserving its previous
intended dependencies. The evaluation guide and AI install index
identify those opt-ins. These address the existing Devin workflow/docs
findings.
- `uv lock --check`, touched Python Ruff/format and whitespace checks
pass. All 253 locked package versions are unchanged; only the root
`[all]` dependency metadata/flattened list changes.
- Real resolver commands from this checkout: `uv export --extra all
--no-dev --locked --no-hashes --no-emit-project` and `uv export --extra
all --extra ml --extra voice --extra evals --no-dev --locked --no-hashes
--no-emit-project`. Evaluating their actual requirement markers for
Python 3.12/3.13/3.14 on Linux x86_64, Windows AMD64, macOS arm64 and
macOS x86_64 shows `[all]` excludes torch, sentence-transformers,
datasets and CUDA/NVIDIA packages in all 12 environments. Explicit
opt-ins retain datasets and torch where supported; Intel macOS still
excludes torch.
- Not tested: a fresh full environment install, GPU runtime, live paid
evaluations or a fresh native build. Hosted CI must qualify the
published final head separately.
### Maintainer current-main requalification
Exact head `f1ed1e0019037e7b53ff9ef548843449c3c7a16f`, upstream main
`c01cf07d943d816cfd9d97e6838ed4e38f1ff9a4`.
Current-main integration against upstream
c01cf07d94. The sole conflict was the
inherited Gemini fixture: adopted main's streamed-body helper after
verifying all six test-function ASTs unchanged. No contributor
dependency policy rewritten. The declared breaking change keeps
Torch-backed ml/memory/evals/voice opt-in while preserving the default
CLI/proxy bundle, image capability and main's lean profile. Evaluation
workflows and guides explicitly request removed extras; current
author/Devin discussion considered.
Fresh verification: 25 dependency/Gemini tests pass; offline uv lock
check resolves 253 packages; changed Python lint/format and
main-relative whitespace pass. Actual locked exports evaluated over 12
OS/Python marker environments (Linux/Windows/macOS, Python 3.10–3.13):
all excludes Torch/NVIDIA dependencies, explicit
all+ml+memory+evals+voice retains Torch. This is resolver/export proof,
not a fresh full installation or GPU runtime claim. No new source
blocker found; formal approval awaits exact-head hosted checks. Nothing
merged.
Exact-head hosted checks are being handled by maintainers. No new
finding in the reviewed scope; formal approval awaits exact-head hosted
qualification; nothing merged.
---------
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
133 lines
4.9 KiB
Python
133 lines
4.9 KiB
Python
"""Dependency contract between Rust ort API 24 and pip ONNX Runtime."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
import tomllib
|
|
from packaging.markers import default_environment
|
|
from packaging.requirements import Requirement
|
|
from packaging.specifiers import SpecifierSet
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_shipping_ort_dependencies_match_supported_platforms() -> None:
|
|
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
|
|
optional = project["optional-dependencies"]
|
|
|
|
cases = [
|
|
("3.11", "darwin", "x86_64", SpecifierSet(">=1.16.0,<1.24.0")),
|
|
("3.13", "darwin", "x86_64", SpecifierSet(">=1.16.0,<1.24.0")),
|
|
("3.14", "darwin", "x86_64", None),
|
|
("3.15", "darwin", "x86_64", None),
|
|
("3.14", "darwin", "arm64", SpecifierSet(">=1.24.0")),
|
|
("3.14", "linux", "x86_64", SpecifierSet(">=1.24.0")),
|
|
("3.11", "darwin", "arm64", SpecifierSet(">=1.24.0")),
|
|
("3.11", "linux", "x86_64", SpecifierSet(">=1.24.0")),
|
|
("3.10", "darwin", "x86_64", SpecifierSet(">=1.16.0,<1.24.0")),
|
|
("3.10", "linux", "x86_64", SpecifierSet(">=1.16.0,<1.24.0")),
|
|
]
|
|
|
|
for extra in ("proxy", "voice"):
|
|
requirements = [
|
|
Requirement(value)
|
|
for value in optional[extra]
|
|
if Requirement(value).name == "onnxruntime"
|
|
]
|
|
assert len(requirements) == 2
|
|
for python_version, sys_platform, platform_machine, expected in cases:
|
|
environment = default_environment()
|
|
environment.update(
|
|
python_version=python_version,
|
|
python_full_version=f"{python_version}.0",
|
|
sys_platform=sys_platform,
|
|
platform_machine=platform_machine,
|
|
extra="",
|
|
)
|
|
selected = [
|
|
req for req in requirements if req.marker and req.marker.evaluate(environment)
|
|
]
|
|
if expected is None:
|
|
assert not selected
|
|
else:
|
|
assert len(selected) == 1
|
|
assert selected[0].specifier == expected
|
|
|
|
|
|
def test_intel_macos_python314_omits_ort_dependent_optional_backends() -> None:
|
|
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
|
|
environment = default_environment()
|
|
environment.update(
|
|
python_version="3.14",
|
|
python_full_version="3.14.0",
|
|
sys_platform="darwin",
|
|
platform_machine="x86_64",
|
|
extra="",
|
|
)
|
|
ort_backends = {"onnxruntime", "magika", "fastembed", "rapidocr", "rapidocr-onnxruntime"}
|
|
for extra in ("proxy", "voice", "relevance", "image"):
|
|
selected = {
|
|
req.name
|
|
for raw in project["optional-dependencies"][extra]
|
|
if (req := Requirement(raw)).marker is None or req.marker.evaluate(environment)
|
|
}
|
|
assert not selected & ort_backends, (extra, selected & ort_backends)
|
|
|
|
|
|
def test_all_extra_includes_proxy_without_torch_dependency_extras() -> None:
|
|
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
|
|
optional = project["optional-dependencies"]
|
|
all_requirements = optional["all"]
|
|
|
|
included_extras = {
|
|
extra
|
|
for raw_requirement in all_requirements
|
|
if (requirement := Requirement(raw_requirement)) and requirement.name == "headroom-ai"
|
|
for extra in requirement.extras
|
|
}
|
|
|
|
assert {"proxy", "image"} <= included_extras
|
|
assert not {"ml", "memory", "evals", "voice"} & included_extras
|
|
assert {"ml", "memory", "evals", "voice", "sandbox"} <= optional.keys()
|
|
|
|
|
|
@pytest.mark.proxy_dependency_gate
|
|
@pytest.mark.parametrize(
|
|
"python_version, sys_platform, platform_machine, optional",
|
|
[
|
|
((3, 14), "darwin", "x86_64", True),
|
|
((3, 15), "darwin", "x86_64", True),
|
|
((3, 13), "darwin", "x86_64", False),
|
|
((3, 14), "darwin", "arm64", False),
|
|
((3, 14), "linux", "x86_64", False),
|
|
],
|
|
)
|
|
def test_proxy_dependency_gate_matches_onnx_platform_markers(
|
|
monkeypatch, python_version, sys_platform, platform_machine, optional
|
|
) -> None:
|
|
import platform
|
|
|
|
from headroom.cli import proxy
|
|
|
|
monkeypatch.setattr(proxy.sys, "version_info", python_version)
|
|
monkeypatch.setattr(proxy.sys, "platform", sys_platform)
|
|
monkeypatch.setattr(platform, "machine", lambda: platform_machine)
|
|
requested = []
|
|
|
|
def find_dependency(name):
|
|
requested.append(name)
|
|
if name in {"magika", "onnxruntime"}:
|
|
return None
|
|
return object()
|
|
|
|
monkeypatch.setattr(proxy, "find_spec", find_dependency)
|
|
if optional:
|
|
proxy.ensure_proxy_dependencies()
|
|
assert not {"magika", "onnxruntime"} & set(requested)
|
|
assert {"fastapi", "uvicorn", "httpx", "mcp", "transformers"} <= set(requested)
|
|
else:
|
|
with pytest.raises(SystemExit, match="1"):
|
|
proxy.ensure_proxy_dependencies()
|