Repository navigation
feat(validation): validate several files per run and look up the schema via OSSIE_SCHEMA - #545
Conversation
…ma via OSSIE_SCHEMA validate.py took exactly one file, so a repository with more than one model had to wrap it in a shell loop and collect exit codes by hand. It now accepts any number of paths, reports each one, prints a summary when there is more than one and exits non-zero if any of them failed. The output for a single file is unchanged. The default schema path assumed this repository's layout, which gives a confusing first error when the script is vendored elsewhere. --schema still wins; otherwise OSSIE_SCHEMA is consulted before the repository default, and the not-found message now says how to point at a schema. The check sequence moves out of main() into validate_document(), so the checks can run on a parsed document without going through the CLI. read_text_or_exit becomes read_text_or_report, returning None instead of exiting, so an unreadable model fails only its own file and the run continues with the next one. Reading and checking the schema moves into load_schema_or_report with the same shape; a bad schema still ends the run. Generated-by: Claude Code
jbonofre
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the multi-file support @kayemkim!
A few minor comments:
- Only YAML parse errors and
RecursionErrorare caught per file. Any other exception (e.g. aTypeErrororKeyErroron unusual input) aborts the whole run with a traceback, so remaining file are not validated and no summary prints. That conflicts a bit with the docstring's "every file is validated and reported". I would like to see a per-file catch-all that reports the failure and continues, maybe in this PR. - The PASSED line prints only
yaml_path.name, soa/model.yamlandb/model.yamllook identical, and warning/error lines carry no path. Printing the full name would make CI logs easier to attribute. - Any starting starting with
-is now reject as an unknown option, and there's no--separator. Files like-model.yamlused to validate. Unlikely to matter in practice, but a--separator would cover it.
|
@kayemkim do you want to tackle first comment in this PR or as follow-up? |
…after -- A check that raises on one document aborted the whole run with a traceback, so the files after it were never validated and no summary printed. validate_file now reports the exception on stdout like any other failure, keeps the traceback on stderr and returns False, so the run continues and the exit status still reflects it. Any argument starting with a dash was rejected as an option, which locked out a file name such as -model.yaml. A -- separator takes the rest of the arguments as file names. Both from review. Generated-by: Claude Code
|
Thanks for the review. I took the first and third in this PR, pushed as a second commit so the diff on top of what you approved stays small. A check that raises now prints
On the PASSED line: in a multi-file run every file's block starts with |
jbonofre
left a comment
There was a problem hiding this comment.
LGTM!
Two small behavior changes in valiidation/validate.py which are completely fine, but worth being aware of:
- any argument starting with
-is now treated as an unknown option, so a file named-foo.ymlnow prints usage and exits 1. The new docstring points to--as the workaround, which is reasonable. - a missing schema is now reported before any input file is checked, so the order of error messages differs from before. Exit codes are unchanged.
Summary
validate.py took exactly one file. It now accepts any number of paths, reports each one, prints a summary when there is more than one and exits non-zero if any file failed, so
validate.py models/*.yamlworks in a CI step without a shell loop. Output for a single file is unchanged, which keeps the converter tests that read it (NVIDIA, Cube) as they are.The default schema path assumed this repository's layout.
--schemastill wins; otherwiseOSSIE_SCHEMAis consulted before the repository default, and the not-found message now says how to point at a schema. I left out the./schema/fallback the issue floated, since the environment variable covers the vendored case without inventing a directory convention.The check sequence itself moved out of
main()intovalidate_document(data, schema), so a caller with a parsed document can run every check, including the ontology checks from #489, without going through the CLI.This sits on top of #534 and #542. The schema is still read and checked once, before the loop, now in
load_schema_or_report. The model side now goes throughread_text_or_report, which prints the same messages #534 added but returns None instead of exiting, so an unreadable file among several fails only itself and the run continues. There is a test for that case alongside the other eleven in validation/tests. #271 changes the reporting lines that moved intovalidate_fileunchanged, so whichever lands second is a small rebase.Verification
validation/tests/: 176 passed,validation/test_validate.py: 53 OK, and the full validation workflow (3.11 to 3.14) run locally on this branch merged into current main.examples/tpcds_semantic_model.yamlis byte-identical to main; the NVIDIA and Cube converter suites, which call or import validate.py, pass unchanged.1 of 4 file(s) passed, exit 1.Related Issues
Follow-up to #266, items 2 and 3 (item 1 was #390).
Checklist
Validation
Tests
pytest/ CI green)Compliance
🤖 Generated with Claude Code