test(api): pre-commit check to ensure API does not import llama_stack (#4160)
Some checks failed
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 4s
Integration Tests (Replay) / generate-matrix (push) Successful in 4s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Test Llama Stack Build / generate-matrix (push) Successful in 5s
Test llama stack list-deps / generate-matrix (push) Successful in 4s
API Conformance Tests / check-schema-compatibility (push) Successful in 11s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 10s
Python Package Build Test / build (3.12) (push) Failing after 7s
Test llama stack list-deps / list-deps-from-config (push) Successful in 40s
Test Llama Stack Build / build-single-provider (push) Successful in 43s
Test llama stack list-deps / list-deps (push) Failing after 38s
Test llama stack list-deps / show-single-provider (push) Successful in 45s
Test External API and Providers / test-external (venv) (push) Failing after 45s
Test Llama Stack Build / build (push) Successful in 42s
Vector IO Integration Tests / test-matrix (push) Failing after 57s
Python Package Build Test / build (3.13) (push) Failing after 1m0s
UI Tests / ui-tests (22) (push) Successful in 1m2s
Unit Tests / unit-tests (3.13) (push) Failing after 1m52s
Test Llama Stack Build / build-ubi9-container-distribution (push) Successful in 2m15s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 2m12s
Test Llama Stack Build / build-custom-container-distribution (push) Successful in 2m26s
Unit Tests / unit-tests (3.12) (push) Failing after 2m33s
Pre-commit / pre-commit (push) Successful in 3m40s

# What does this PR do?

since llama_stack_api is meant to be _just_ the API definitions of LLS,
we should have pre-commit check that prohibits anyone from accidentally
importing `from llama_stack` or adding `llama_stack` as a dependency
into `llama_stack_api`s pyproject.


## Test Plan

pre-commit should pass.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
Charlie Doern 2025-11-17 16:23:43 -05:00 committed by GitHub
parent 7d3db6b22c
commit 29f1fa6abd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -199,6 +199,27 @@ repos:
echo; echo;
exit 1; exit 1;
} || true } || true
- id: check-api-independence
name: Ensure llama_stack_api does not import llama_stack
entry: bash
language: system
pass_filenames: false
require_serial: true
always_run: true
files: ^src/llama_stack_api/.*$
args:
- -c
- |
API_DIR="src/llama_stack_api"
grep -rn --include="*.py" -E '^[^#]*(import llama_stack\b|from llama_stack\b)' "$API_DIR" 2>/dev/null && {
echo "llama_stack_api must not import llama_stack";
exit 1;
}
[ -f "$API_DIR/pyproject.toml" ] && grep -n 'llama_stack[^_]' "$API_DIR/pyproject.toml" && {
echo "llama_stack_api must not depend on llama_stack in pyproject.toml";
exit 1;
}
exit 0
ci: ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks