From a213134f1a719920151d53a52c9f00fe6ed19c29 Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Fri, 14 Nov 2025 13:56:15 -0500 Subject: [PATCH] test(api): pre-commit check to ensure API does not import llama_stack since llama_stack_api is meant to be _just_ the API definitions of LLS, we should have a check in pre-commit that prohibits anyone from accidentally importing `from llama_stack` or adding `llama_stack` as a dependency into `llama_stack_api`s pyproject. Signed-off-by: Charlie Doern --- .pre-commit-config.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c60440173..995332b80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -200,6 +200,27 @@ repos: echo; exit 1; } || 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: autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks