You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4f7524b
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Fix --models flag being silently ignored by e2e golden tests (#217)
### Problem
The `--models` flag passed from CI workflows
(`gpu_l4_golden_parity.yml`, `gpu_l5_generation_e2e.yml`) was silently
ignored by the e2e golden tests. All ~214 golden tests ran every time,
regardless of which models were actually affected.
**Root cause:** The `pytest_collection_modifyitems` hook in
`tests/conftest.py` filters tests by checking for a `model_type`
parameter in `item.callspec.params`. But golden tests are parametrized
with a `case` object (`GoldenTestCase`), not `model_type`. The hook hit
`continue` and skipped filtering entirely.
### Fix
Added an explicit `model_type` field to the golden test YAML schema and
wired it through to the filtering hook.
**Changes:**
| File | Change |
|------|--------|
| `testdata/cases/schema.json` | Added `model_type` to `required` and
`properties` |
| `src/mobius/_testing/golden.py` | Added `model_type: str` field to
`GoldenTestCase`, extracted in `load_test_case()` |
| `tests/conftest.py` | Extended `--models` hook to check
`case.model_type` for golden test items |
| `testdata/cases/**/*.yaml` (214 files) | Added `model_type` line to
each YAML case file |
### Why this approach
- **Declarative, not runtime:** `model_type` is a static YAML field — no
reverse-map lookups, no registry imports in test infra, no network calls
at collection time.
- **Fails closed:** Missing `model_type` causes a schema validation
error (`yaml_schema_test.py`) and a `load_test_case()` `ValueError`. New
YAML cases can't silently bypass the filter.
- **Consistent:** Same pattern as `model_id`, `task_type`, `dtype` —
already-required fields in the schema.
### Verification
| Test | Result |
|------|--------|
| `pytest tests/yaml_schema_test.py` | 218 passed — all YAMLs valid |
| `--models qwen2` | 343 skipped, only qwen2 tests ran |
| `--models nonexistent` | 345 skipped — all golden tests filtered out |
| `--models llama` on `build_graph_test.py` | Existing filtering
unchanged |
---------
Co-authored-by: Tommaso Adani <[email protected]>
Co-authored-by: Justin Chu <[email protected]>
Copy file name to clipboardExpand all lines: .agents/skills/writing-tests/references/test-examples.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,10 +111,11 @@ Guidelines for choosing models:
111
111
Categories match task types: `causal-lm`, `encoder`, `seq2seq`, `audio`,
112
112
`vision`, `vision-language`, `diffusion`.
113
113
114
-
**Required fields:**
114
+
**Required fields** (enforced by `testdata/cases/schema.json`; `tests/yaml_schema_test.py` validates every YAML on every PR):
115
115
116
116
```yaml
117
117
model_id: "Qwen/Qwen2.5-1.5B-Instruct"# HuggingFace model ID
118
+
model_type: "qwen2"# HF config.model_type — must match a key in mobius._registry
118
119
revision: "main"# Git revision / commit SHA
119
120
task_type: "text-generation"# Task type string
120
121
dtype: "float32"# "float32", "float16", or "bfloat16"
@@ -125,6 +126,8 @@ inputs:
125
126
- "Here is my poem:"# Text prompt(s); use this default
126
127
```
127
128
129
+
`model_type` is the value the registry lookup uses (see `_create_default_registry()` in `src/mobius/_registry.py`). It is **also** what `tests/model_coverage_test.py` keys on — every registered `model_type` must either appear in some YAML's `model_type` field or be added to `_COVERAGE_SKIP` with a reason. Omit it and the schema test fails; provide a value the registry doesn't know and the coverage test still flags it.
130
+
128
131
For image models, use `images:` instead of (or alongside) `prompts:`:
129
132
130
133
```yaml
@@ -209,8 +212,11 @@ Golden files must be committed alongside new test case YAML files.
0 commit comments