Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,44 @@ jobs:
python -m pip install pip==26.0.1
pip install -e ".[dev,test,performance]"
pip-audit

schema-updated:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Check for schema changes
id: schema
run: |
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- \
'src/inference_endpoint/config/schema.py' \
'src/inference_endpoint/endpoint_client/config.py' \
'src/inference_endpoint/commands/benchmark/cli.py' \
'scripts/regenerate_templates.py' \
'src/inference_endpoint/config/templates/*.yaml')
echo "changed=$([[ -n "$CHANGED" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"

- name: Set up Python 3.12
if: steps.schema.outputs.changed == 'true'
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"

- name: Install dependencies
if: steps.schema.outputs.changed == 'true'
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"

- name: Run schema fuzz tests
if: steps.schema.outputs.changed == 'true'
run: |
pytest -xv -m schema_fuzz

- name: Check YAML templates are up to date
if: steps.schema.outputs.changed == 'true'
run: |
python scripts/regenerate_templates.py --check
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
hooks:
- id: prettier
types_or: [yaml, json, markdown]
exclude: ^(src/inference_endpoint/openai/openai_types_gen.py|src/inference_endpoint/openai/openapi.yaml)$
exclude: ^(src/inference_endpoint/openai/openai_types_gen.py|src/inference_endpoint/openai/openapi.yaml|src/inference_endpoint/config/templates/)

- repo: local
hooks:
Expand All @@ -48,12 +48,12 @@ repos:
args: ["--tb=short", "--strict-markers"]
stages: [manual]

- id: validate-templates
name: Validate YAML templates against schema
entry: python -c "from pathlib import Path; from inference_endpoint.config.schema import BenchmarkConfig; [BenchmarkConfig.from_yaml_file(f) for f in sorted(Path('src/inference_endpoint/config/templates').glob('*.yaml'))]"
- id: regenerate-templates
name: Regenerate YAML templates from schema defaults
entry: python scripts/regenerate_templates.py
language: system
pass_filenames: false
files: ^src/inference_endpoint/config/(schema\.py|templates/)
files: ^(src/inference_endpoint/config/(schema\.py|templates/.*)|src/inference_endpoint/endpoint_client/config\.py|scripts/regenerate_templates\.py)$

- id: add-license-header
name: Add license headers
Expand Down
13 changes: 11 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ src/inference_endpoint/
│ ├── ruleset_registry.py # Ruleset registry
│ ├── user_config.py # UserConfig dataclass for ruleset user overrides
│ ├── rulesets/mlcommons/ # MLCommons-specific rules, datasets, models
│ └── templates/ # YAML config templates (offline, online, eval, etc.)
│ └── templates/ # YAML config templates (_template.yaml minimal, _template_full.yaml all defaults)
├── openai/ # OpenAI-compatible API types and adapters
│ ├── types.py # OpenAI response types
│ ├── openai_adapter.py # Request/response adapter
Expand Down Expand Up @@ -204,7 +204,16 @@ tests/
- **License headers**: Required on all Python files (enforced by pre-commit hook `scripts/add_license_header.py`)
- **Conventional commits**: `feat:`, `fix:`, `docs:`, `test:`, `chore:`

All of these hooks run automatically on commit: trailing-whitespace, end-of-file-fixer, check-yaml, check-merge-conflict, debug-statements, `ruff` (lint + autofix), `ruff-format`, `mypy`, `prettier` (YAML/JSON/Markdown), license header enforcement.
### Pre-commit Hooks

All of these run automatically on commit:

- trailing-whitespace, end-of-file-fixer, check-yaml, check-merge-conflict, debug-statements
- `ruff` (lint + autofix) and `ruff-format`
- `mypy` type checking
- `prettier` for YAML/JSON/Markdown
- License header enforcement
- `regenerate-templates`: auto-regenerates YAML config templates from schema defaults when `schema.py`, `config.py`, or `regenerate_templates.py` change

**Always run `pre-commit run --all-files` before committing.**

Expand Down
15 changes: 15 additions & 0 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ pytest -s -v
python -m pdb -m pytest test_file.py
```

## YAML Config Templates

Config templates in `src/inference_endpoint/config/templates/` are auto-generated from schema defaults. When you change `config/schema.py`, regenerate them:

```bash
python scripts/regenerate_templates.py
```

The pre-commit hook auto-regenerates templates when `schema.py`, `config.py`, or `regenerate_templates.py` change. CI validates templates are up to date via `--check` mode.

Two variants are generated per mode (offline, online, concurrency):

- `_template.yaml` — minimal: only required fields + placeholders
- `_template_full.yaml` — all fields with schema defaults + inline `# options:` comments

## Package Management

### Adding Dependencies
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ test = [
"aiohttp==3.13.5",
# Plotting for benchmark sweep mode
"matplotlib==3.10.8",
# Property-based testing (CLI fuzz)
"hypothesis==6.151.10",
]
performance = [
"pytest-benchmark==5.2.3",
Expand Down Expand Up @@ -184,6 +186,7 @@ markers = [
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
"run_explicitly: mark test to only run explicitly",
"schema_fuzz: hypothesis CLI fuzz tests (run in CI on schema changes)",
]
filterwarnings = [
"ignore:Session timeout reached:RuntimeWarning",
Expand Down
Loading
Loading