fix(schemas): silence Pydantic protected-namespace warning on ModelProvenance
Browse filesThe model_version field in T2's ModelProvenance triggers Pydantic v2's
"model_*" protected-namespace UserWarning. Our DoD gate runs
pytest -W error::UserWarning, which would escalate this to a hard
error during T4 close-out. Set protected_namespaces=() on this single
schema to keep the field name as designed without weakening the gate.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/api/schemas.py +5 -1
src/api/schemas.py
CHANGED
|
@@ -6,7 +6,7 @@ can render a single result card regardless of modality.
|
|
| 6 |
"""
|
| 7 |
from __future__ import annotations
|
| 8 |
|
| 9 |
-
from pydantic import BaseModel, Field
|
| 10 |
|
| 11 |
|
| 12 |
class BBBRequest(BaseModel):
|
|
@@ -72,6 +72,10 @@ class CalibrationContext(BaseModel):
|
|
| 72 |
|
| 73 |
class ModelProvenance(BaseModel):
|
| 74 |
"""Auditable provenance of the BBB model that produced a prediction."""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
mlflow_run_id: str | None = Field(None, description="MLflow run id of the most recent training run, if any")
|
| 76 |
model_version: str = Field("v1", description="Manually-bumped model version label")
|
| 77 |
train_date: str | None = Field(None, description="ISO 8601 train timestamp from MLflow run start_time")
|
|
|
|
| 6 |
"""
|
| 7 |
from __future__ import annotations
|
| 8 |
|
| 9 |
+
from pydantic import BaseModel, ConfigDict, Field
|
| 10 |
|
| 11 |
|
| 12 |
class BBBRequest(BaseModel):
|
|
|
|
| 72 |
|
| 73 |
class ModelProvenance(BaseModel):
|
| 74 |
"""Auditable provenance of the BBB model that produced a prediction."""
|
| 75 |
+
# Disable the `model_` protected-namespace check so `model_version` doesn't
|
| 76 |
+
# trip Pydantic v2's UserWarning (which our DoD gate escalates to error).
|
| 77 |
+
model_config = ConfigDict(protected_namespaces=())
|
| 78 |
+
|
| 79 |
mlflow_run_id: str | None = Field(None, description="MLflow run id of the most recent training run, if any")
|
| 80 |
model_version: str = Field("v1", description="Manually-bumped model version label")
|
| 81 |
train_date: str | None = Field(None, description="ISO 8601 train timestamp from MLflow run start_time")
|