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:
torbenandClaude Sonnet 5.5 committed 2026-12-04 23:16:48 +01:00
1 parent 42f8be0aea
commit e9c5913025
1 file changed
+3 -3
+3 -3
View File
@@ -34,7 +34,7 @@ for _first in "tTfF":
_Loader.yaml_implicit_resolvers = _resolvers _Loader.yaml_implicit_resolvers = _resolvers
def _read_yaml(path: Path) -> dict[str, Any]: def read_yaml(path: Path) -> dict[str, Any]:
try: try:
text = path.read_text(encoding="utf-8-sig") text = path.read_text(encoding="utf-8-sig")
except FileNotFoundError: except FileNotFoundError:
@@ -70,7 +70,7 @@ def _resolve_output_model(spec: str, path: Path) -> type[BaseModel]:
def load_eval_set(directory: Path) -> EvalSet: def load_eval_set(directory: Path) -> EvalSet:
spec_path = directory / "eval.yaml" spec_path = directory / "eval.yaml"
try: 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: except ValidationError as exc:
raise EvalSetError( raise EvalSetError(
f"{spec_path}: invalid content: {describe_validation_error(exc)}" 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": if not stray.name.startswith(".") and stray.suffix != ".yaml":
raise EvalSetError(f"{stray}: case files must end in .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): 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: if "id" in data:
raise EvalSetError(f"{case_path}: invalid case: 'id' is the file name, not a field") raise EvalSetError(f"{case_path}: invalid case: 'id' is the file name, not a field")
try: try: