mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
Some checks failed
Pre-commit / pre-commit (push) Successful in 3m27s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 0s
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 0s
Integration Tests (Replay) / generate-matrix (push) Successful in 3s
Test Llama Stack Build / generate-matrix (push) Successful in 3s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Test llama stack list-deps / generate-matrix (push) Successful in 3s
Python Package Build Test / build (3.12) (push) Failing after 4s
API Conformance Tests / check-schema-compatibility (push) Successful in 11s
Test llama stack list-deps / show-single-provider (push) Successful in 25s
Test External API and Providers / test-external (venv) (push) Failing after 34s
Vector IO Integration Tests / test-matrix (push) Failing after 43s
Test Llama Stack Build / build (push) Successful in 37s
Test Llama Stack Build / build-single-provider (push) Successful in 48s
Test llama stack list-deps / list-deps-from-config (push) Successful in 52s
Test llama stack list-deps / list-deps (push) Failing after 52s
Python Package Build Test / build (3.13) (push) Failing after 1m2s
UI Tests / ui-tests (22) (push) Successful in 1m15s
Test Llama Stack Build / build-custom-container-distribution (push) Successful in 1m29s
Unit Tests / unit-tests (3.12) (push) Failing after 1m45s
Test Llama Stack Build / build-ubi9-container-distribution (push) Successful in 1m54s
Unit Tests / unit-tests (3.13) (push) Failing after 2m13s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 2m20s
# What does this PR do?
This replaces the legacy "pyopenapi + strong_typing" pipeline with a
FastAPI-backed generator that has an explicit schema registry inside
`llama_stack_api`. The key changes:
1. **New generator architecture.** FastAPI now builds the OpenAPI schema
directly from the real routes, while helper modules
(`schema_collection`, `endpoints`, `schema_transforms`, etc.)
post-process the result. The old pyopenapi stack and its strong_typing
helpers are removed entirely, so we no longer rely on fragile AST
analysis or top-level import side effects.
2. **Schema registry in `llama_stack_api`.** `schema_utils.py` keeps a
`SchemaInfo` record for every `@json_schema_type`, `register_schema`,
and dynamically created request model. The OpenAPI generator and other
tooling query this registry instead of scanning the package tree,
producing deterministic names (e.g., `{MethodName}Request`), capturing
all optional/nullable fields, and making schema discovery testable. A
new unit test covers the registry behavior.
3. **Regenerated specs + CI alignment.** All docs/Stainless specs are
regenerated from the new pipeline, so optional/nullable fields now match
reality (expect the API Conformance workflow to report breaking
changes—this PR establishes the new baseline). The workflow itself is
back to the stock oasdiff invocation so future regressions surface
normally.
*Conformance will be RED on this PR; we choose to accept the
deviations.*
## Test Plan
- `uv run pytest tests/unit/server/test_schema_registry.py`
- `uv run python -m scripts.openapi_generator.main docs/static`
---------
Signed-off-by: Sébastien Han <seb@redhat.com>
Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
210 lines
6.9 KiB
YAML
210 lines
6.9 KiB
YAML
exclude: 'build/'
|
|
minimum_pre_commit_version: 4.4.0
|
|
default_language_version:
|
|
python: python3.12
|
|
node: "22"
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v5.0.0 # Latest stable version
|
|
hooks:
|
|
- id: check-merge-conflict
|
|
args: ['--assume-in-merge']
|
|
- id: trailing-whitespace
|
|
exclude: '\.py$' # Exclude Python files as Ruff already handles them
|
|
- id: check-added-large-files
|
|
args: ['--maxkb=1000']
|
|
- id: end-of-file-fixer
|
|
exclude: '^(.*\.svg|.*\.md)$'
|
|
- id: no-commit-to-branch
|
|
- id: check-yaml
|
|
args: ["--unsafe"]
|
|
- id: detect-private-key
|
|
- id: mixed-line-ending
|
|
args: [--fix=lf] # Forces to replace line ending by LF (line feed)
|
|
- id: check-executables-have-shebangs
|
|
- id: check-json
|
|
- id: check-shebang-scripts-are-executable
|
|
- id: check-symlinks
|
|
- id: check-toml
|
|
|
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
|
rev: v1.5.5
|
|
hooks:
|
|
- id: insert-license
|
|
files: \.py$|\.sh$
|
|
args:
|
|
- --license-filepath
|
|
- docs/license_header.txt
|
|
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
rev: v0.12.2
|
|
hooks:
|
|
- id: ruff
|
|
args: [ --fix ]
|
|
- id: ruff-format
|
|
|
|
- repo: https://github.com/adamchainz/blacken-docs
|
|
rev: 1.19.1
|
|
hooks:
|
|
- id: blacken-docs
|
|
additional_dependencies:
|
|
- black==24.3.0
|
|
|
|
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: v1.18.2
|
|
hooks:
|
|
- id: mypy
|
|
additional_dependencies:
|
|
- uv==0.6.2
|
|
- mypy
|
|
- pytest
|
|
- rich
|
|
- types-requests
|
|
- pydantic
|
|
pass_filenames: false
|
|
|
|
# - repo: https://github.com/tcort/markdown-link-check
|
|
# rev: v3.11.2
|
|
# hooks:
|
|
# - id: markdown-link-check
|
|
# args: ['--quiet']
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: uv-lock
|
|
name: uv-lock
|
|
additional_dependencies:
|
|
- uv==0.7.20
|
|
entry: ./scripts/uv-run-with-index.sh lock
|
|
language: python
|
|
pass_filenames: false
|
|
require_serial: true
|
|
files: ^(pyproject\.toml|uv\.lock)$
|
|
- id: mypy-full
|
|
name: mypy (full type_checking)
|
|
entry: ./scripts/uv-run-with-index.sh run --group dev --group type_checking mypy
|
|
language: system
|
|
pass_filenames: false
|
|
stages: [manual]
|
|
- id: distro-codegen
|
|
name: Distribution Template Codegen
|
|
additional_dependencies:
|
|
- uv==0.7.8
|
|
entry: ./scripts/uv-run-with-index.sh run --group codegen ./scripts/distro_codegen.py
|
|
language: python
|
|
pass_filenames: false
|
|
require_serial: true
|
|
files: ^src/llama_stack/distributions/.*$|^src/llama_stack/providers/.*/inference/.*/models\.py$
|
|
- id: provider-codegen
|
|
name: Provider Codegen
|
|
additional_dependencies:
|
|
- uv==0.7.8
|
|
entry: ./scripts/uv-run-with-index.sh run --group codegen ./scripts/provider_codegen.py
|
|
language: python
|
|
pass_filenames: false
|
|
require_serial: true
|
|
files: ^src/llama_stack/providers/.*$|^scripts/run_openapi_generator.sh$
|
|
- id: openapi-codegen
|
|
name: API Spec Codegen
|
|
additional_dependencies:
|
|
- uv==0.7.8
|
|
entry: sh -c './scripts/uv-run-with-index.sh run scripts/run_openapi_generator.sh'
|
|
language: python
|
|
pass_filenames: false
|
|
require_serial: true
|
|
files: ^src/llama_stack_api/.*$
|
|
- id: check-workflows-use-hashes
|
|
name: Check GitHub Actions use SHA-pinned actions
|
|
entry: ./scripts/check-workflows-use-hashes.sh
|
|
language: system
|
|
pass_filenames: false
|
|
require_serial: true
|
|
always_run: true
|
|
files: ^\.github/workflows/.*\.ya?ml$
|
|
- id: check-init-py
|
|
name: Check for missing __init__.py files
|
|
entry: ./scripts/check-init-py.sh
|
|
language: system
|
|
pass_filenames: false
|
|
require_serial: true
|
|
always_run: true
|
|
files: ^src/llama_stack/.*$
|
|
- id: forbid-pytest-asyncio
|
|
name: Block @pytest.mark.asyncio and @pytest_asyncio.fixture
|
|
entry: bash
|
|
language: system
|
|
types: [python]
|
|
pass_filenames: true
|
|
args:
|
|
- -c
|
|
- |
|
|
grep -EnH '^[^#]*@pytest\.mark\.asyncio|@pytest_asyncio\.fixture' "$@" && {
|
|
echo;
|
|
echo "❌ Do not use @pytest.mark.asyncio or @pytest_asyncio.fixture."
|
|
echo " pytest is already configured with async-mode=auto."
|
|
echo;
|
|
exit 1;
|
|
} || true
|
|
- id: generate-ci-docs
|
|
name: Generate CI documentation
|
|
additional_dependencies:
|
|
- uv==0.7.8
|
|
entry: ./scripts/uv-run-with-index.sh run ./scripts/gen-ci-docs.py
|
|
language: python
|
|
pass_filenames: false
|
|
require_serial: true
|
|
files: ^.github/workflows/.*$
|
|
- id: ui-linter
|
|
name: Format & Lint UI
|
|
entry: bash ./scripts/run-ui-linter.sh
|
|
language: system
|
|
files: ^src/llama_stack_ui/.*\.(ts|tsx)$
|
|
pass_filenames: false
|
|
require_serial: true
|
|
|
|
- id: check-log-usage
|
|
name: Ensure 'llama_stack.log' usage for logging
|
|
entry: bash
|
|
language: system
|
|
types: [python]
|
|
pass_filenames: true
|
|
args:
|
|
- -c
|
|
- |
|
|
matches=$(grep -EnH '^[^#]*\b(import\s+logging|from\s+logging\b)' "$@" | grep -v -e '#\s*allow-direct-logging' || true)
|
|
if [ -n "$matches" ]; then
|
|
# GitHub Actions annotation format
|
|
while IFS=: read -r file line_num rest; do
|
|
echo "::error file=$file,line=$line_num::Do not use 'import logging' or 'from logging import' in $file. Use the custom log instead: from llama_stack.log import get_logger; logger = get_logger(). If direct logging is truly needed, add: # allow-direct-logging"
|
|
done <<< "$matches"
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
- id: fips-compliance
|
|
name: Ensure llama-stack remains FIPS compliant
|
|
entry: bash
|
|
language: system
|
|
types: [python]
|
|
pass_filenames: true
|
|
exclude: '^tests/.*$' # Exclude test dir as some safety tests used MD5
|
|
args:
|
|
- -c
|
|
- |
|
|
grep -EnH '^[^#]*\b(md5|sha1|uuid3|uuid5)\b' "$@" && {
|
|
echo;
|
|
echo "❌ Do not use any of the following functions: hashlib.md5, hashlib.sha1, uuid.uuid3, uuid.uuid5"
|
|
echo " These functions are not FIPS-compliant"
|
|
echo;
|
|
exit 1;
|
|
} || true
|
|
|
|
ci:
|
|
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
|
|
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
|
|
autofix_prs: true
|
|
autoupdate_branch: ''
|
|
autoupdate_schedule: weekly
|
|
skip: []
|
|
submodules: false
|