Make loader read_yaml public
The baseline reader needs the same YAML dialect for old case files. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
42f8be0aea
commit
e9c5913025
1 file changed
+3
-3
@@ -34,7 +34,7 @@ for _first in "tTfF":
|
||||
_Loader.yaml_implicit_resolvers = _resolvers
|
||||
|
||||
|
||||
def _read_yaml(path: Path) -> dict[str, Any]:
|
||||
def read_yaml(path: Path) -> dict[str, Any]:
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8-sig")
|
||||
except FileNotFoundError:
|
||||
@@ -70,7 +70,7 @@ def _resolve_output_model(spec: str, path: Path) -> type[BaseModel]:
|
||||
def load_eval_set(directory: Path) -> EvalSet:
|
||||
spec_path = directory / "eval.yaml"
|
||||
try:
|
||||
spec = SetSpec.model_validate(_read_yaml(spec_path), strict=True)
|
||||
spec = SetSpec.model_validate(read_yaml(spec_path), strict=True)
|
||||
except ValidationError as exc:
|
||||
raise EvalSetError(
|
||||
f"{spec_path}: invalid content: {describe_validation_error(exc)}"
|
||||
@@ -85,7 +85,7 @@ def load_eval_set(directory: Path) -> EvalSet:
|
||||
if not stray.name.startswith(".") and stray.suffix != ".yaml":
|
||||
raise EvalSetError(f"{stray}: case files must end in .yaml")
|
||||
for case_path in sorted(cases_dir.glob("*.yaml"), key=lambda p: p.stem):
|
||||
data = _read_yaml(case_path)
|
||||
data = read_yaml(case_path)
|
||||
if "id" in data:
|
||||
raise EvalSetError(f"{case_path}: invalid case: 'id' is the file name, not a field")
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user