Repository navigation
fix(benchmark): name the manifest once in validation errors - #1181
Merged
Merged
Conversation
Contributor
|
@bfs2021 is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @bfs2021, your first PR on Fair Code, that's awesome, thank you. This project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly. If you haven't already, give the contributing guide a quick read: it covers how audits are structured and what we look for in a review. And if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A manifest validation error prints the manifest path twice:
Fixes #1179.
Root cause
Manifest.from_dictraisesf"{manifest_path}: protected_attributes must have at least one entry", andrun_benchmarkwraps everyValueErrorfrom its per-manifesttrywithf"{path}: {exc}"so that errors without context (bad YAML, a missing key, a degenerate dataset) still name the manifest. For validation errors that already carry the path, the prefix lands twice.Fix
run_benchmarknow adds the path only when the error message does not already start with it. The path is still printed once for every failure, andManifest.from_dictkeeps its own context for direct/library callers such asload_audit.Testing
test_run_benchmark_names_the_manifest_once_in_validation_errors: asserts the message contains the manifest path exactly once (fails on the old code with 2 occurrences).python -m faircode benchmark m2.yamlnow printserror: m2.yaml: protected_attributes must have at least one entry.python -m pytest tests/test_benchmark.py -q -k "validation_errors"→ passes;ruff check→ clean. The three..._with_manifest_pathtests fail on this Windows box both before and after the change becausepytest.raises(match=...)compiles the backslashed path as a regex (incomplete escape \U) — verified by stashing the change.