Repository navigation
feat(cli): accept multiple data files in 'validate data' - #49
Conversation
'validate data' previously took a single DATA_FILE, so validating many files required one process per file — each re-parsing the schema and rebuilding the Validator (the expensive step). This made bulk validation (e.g. thousands of curation files in CI) dominated by per-file process/schema startup. Make 'validate data' accept one or more DATA_FILE arguments (mirroring linkml-term-validator's 'validate-data DATA_PATHS...'). The config, plugin, and Validator are built once and reused across all files; each file is validated independently with per-file reporting and a combined exit code (non-zero if any file has issues). Single-file usage is unchanged (a one-element list). Smoke test on real data: 10 files in one process ~2.1s vs ~12s as 10 processes (~6x), with the gap widening as file count grows. Adds multi-file CLI tests (mixed valid/invalid and all-valid).
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the CLI bulk-validation workflow by allowing validate data to accept multiple data files in a single invocation, reusing the parsed LinkML schema and Validator across files to avoid repeated startup cost.
Changes:
- Update
validate datato acceptDATA_FILE...(one or more files) and validate each file independently while reusing a singleValidatorinstance. - Add CLI tests covering multi-file behavior for mixed valid/invalid inputs and all-valid inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/linkml_reference_validator/cli/validate.py |
Accept multiple input files and reuse a single LinkML Validator; aggregate per-file results into one exit status. |
tests/test_cli.py |
Add tests verifying multi-file invocation behavior and exit codes. |
| else: | ||
| typer.echo(f"Error: Unexpected data format in {data_file}", err=True) | ||
| files_with_issues += 1 | ||
| continue |
Per Copilot review on #49: a data file that loads to an unexpected YAML type (e.g. an empty file -> None, or a bare scalar) logged an error and `continue`d, incrementing files_with_issues but not total_results. Since the exit decision keyed only off total_results, such a file -- with no other failing files -- printed "All validations passed!" and exited 0, silently greenlighting malformed input in CI. Base the exit status on files_with_issues (which already counts both validation failures and unreadable files) and report the count honestly. Adds a parametrized test covering empty-file and bare-scalar input -> exit 1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @cmungall's task in 57s —— View job PR Review: accept multiple data files in
|
Motivation
validate datatakes a singleDATA_FILE, so validating many files means oneprocess per file — and each process re-parses the LinkML schema and rebuilds the
Validator, which is the expensive step. For bulk validation (e.g. thousands ofcuration YAMLs in CI) this is dominated by per-file process + schema startup, not
the actual validation work. (
linkml-term-validatoralready acceptsDATA_PATHS...for exactly this reason.)Change
Make
validate dataaccept one or moreDATA_FILEarguments. The config,ReferenceValidationPlugin, andValidatorare constructed once and reusedacross all files. Each file is validated independently with per-file reporting,
and the command exits non-zero if any file has issues.
single-file output strings (
All validations passed!,Issues found,[severity] message) are preserved.reported; all-valid → exit 0).
Impact
Smoke test on real data (cached references): 10 files in one process ≈ 2.1 s
vs ≈ 12 s as ten separate processes (~6×), and the gap widens with file count
since the schema is parsed once.
All existing tests pass (
516 passed), mypy and ruff clean.