Skip to content

CI: batch validation of changed KB files (per-file just validate loop times out on large PRs) #5088

Closed

Description

@cmungall

Problem

The test job in .github/workflows/main.yaml validates changed KB files with a per-file loop:

# .github/workflows/main.yaml — "Validate changed disorder KB files"
for f in ${{ steps.changes.outputs.kb_disorders_files }}; do
  ...
  just validate "$f"
done

Each just validate "$f" (project.justfile:69) runs three validators, and every one re-parses the full schema (and the term validator also loads OAK adapters, the reference validator may hit the network):

uv run linkml-validate --schema {{schema_path}} --target-class Disease {{file}}   # schema
{{term_validator}} validate-data {{file}} -s {{schema_path}} ...                  # term (+OAK)
{{ref_validator}} validate data {{file}} --schema {{schema_path}} ...             # reference

So cost scales as O(changed_files) × (3 schema loads + OAK + network). linkml-validate alone is ~10 s/file locally; all three together are much more. This is fine for typical curation PRs (a handful of files) but does not scale to large PRs.

Evidence (PR #5078)

The prevalence remodel (#5078) changed 463 disorder files. test (3.13) cleared every other step (scope guard, ruff, term-reference validation, folded-scalar check) and then died at ~1h46m mid-way through the per-file validation loop (runner resource/time exhaustion; steps after it never ran). The data itself is fine — all 463 files validate locally in a single batched linkml-validate call in ~2 min, and the full test suite passes. The failure is purely the per-file loop's cost, not a data error.

Proposed fix: batch the validators (one process over all changed files)

Replace the per-file loop with one invocation per validator over the whole changed-file list, so the schema/OAK are loaded once:

  • linkml-validate --schema … --target-class Disease F1 F2 … FN (accepts multiple files)
  • linkml-reference-validator validate data F1 … FN … (multi-file; scripts/run_reference_validator.sh already exists and can take multiple files)
  • term validator batched similarly (may need a version bump for multi-file support)

Expected: the ~77+ min (and growing) per-file phase drops to a few minutes, and large migration PRs stop timing out.

Prior art — how ai4curation/ai-gene-review solved the same problem

  • ai4curation/ai-gene-review#1522 — consolidated ~2,670 per-file linkml-reference-validator processes into a single batched validate data F1..FN call (run_reference_validator.sh takes multiple files; project.justfile runs references as one batch step; added --no-references to the per-file best-practices pass to avoid duplication; bumped linkml-reference-validator==0.2.1rc1 for multi-file support). ~4.5× locally; ~60 min → a few minutes.
  • ai4curation/ai-gene-review#1527 — reference-cache warming: pre-populate cache with full_text_attempted markers so the reference validator stops making per-run network calls (~30× on the reference phase). Complementary to batching; dismech's committed references_cache/ may benefit from the same treatment.

Suggested steps

  1. Add a batched validate recipe (e.g. validate-batch FILES...) that calls each validator once over all files.
  2. Update the three main.yaml validate steps (disorders, comorbidities, history) to pass the full changed-file list to the batched recipe instead of looping.
  3. Confirm the term/reference validators support multi-file input (bump versions if needed, per Enhance phenotype section: Fibrodysplasia Ossificans Progressiva #1522).
  4. Optionally warm/verify references_cache/ (per Enhance phenotype section: Spondylocarpotarsal Synostosis Syndrome #1527) to remove network calls from CI.

Priority

Medium — not a data-quality issue, but it blocks large migration/refactor PRs from ever passing CI (currently worked around only by admin-merge or scope-override). Fixing it unblocks this whole class of PR and speeds up every run.

Context: surfaced by #5078 (approved, all data valid locally, blocked solely by this timeout).

Activity

  1. github-actions commented on Jul 1, 2026

    @github-actions
    Contributor

    Summary

    This issue is the CI-facing half of a problem already partly tackled in #4448 ("Speed up validate-all: batch the per-file validation loop"). #4448 targeted the local just qc / validate-all path; this issue is about the CI PR-time path (main.yaml's per-changed-file loop), surfaced concretely when PR #5078 (the 463-file prevalence remodel, now approved after 6 rounds of ai4c-agent review) died at ~1h46m mid-loop with a runner timeout — a pure CI-cost failure, not a data problem (all 463 files validate locally in ~2 min when batched).

    What's already done (from #4448 → PR #4938)

    I checked the current project.justfile / main.yaml state directly:

    So the remaining gap is specifically: schema + term + reference validation of the CI changed-file list, not the full-corpus weekly run (#4448's original scope).

    Proposed fix (as written in the issue body, confirmed still accurate)

    Add a validate-batch FILES... recipe that runs each of the three validators once over the whole changed-file list, and swap it in for the for f in ...; do just validate "$f"; done loops in main.yaml for both disorders and comorbidities. This mirrors the pattern ai4curation/ai-gene-review already validated in production (PR ai4curation/ai-gene-review#1522, ~4.5× speedup, 60 min → a few minutes) and reuses the multi-file support already proven for validate-schema-all/validate-terms-all in this repo.

    One open technical question from #4448 still applies here: linkml-reference-validator multi-file support needs the >=0.2.0 version (currently pinned >=0.1.8 in pyproject.toml), which switches to ruamel's strict CParser (rejects flow-style CURIE lists and duplicate keys — #4448 confirmed the current kb/*.yaml corpus is clean, but worth re-checking after 463 new files from #5078).

    No human assignee on this issue

    I don't see anyone assigned, so per the automation policy I'm invoking the autonomous agent below.


    @dragon-ai-agent please implement the CI batch-validation fix described in this issue, scoped to the changed-file CI path (not the full local validate-all, which #4448/PR #4938 partially handled already):

    1. Add a validate-batch FILES... (or similarly named) recipe to project.justfile that runs linkml-validate, the term validator, and the reference validator each once over the full list of passed files (reuse the batching pattern already working in validate-schema-all/validate-terms-all), instead of the current single-file validate recipe's per-file three-validator design.
    2. Update .github/workflows/main.yaml's "Validate changed disorder KB files" step (~line 141) and "Validate changed comorbidity KB files" step (~line 158) to call the batched recipe once over steps.changes.outputs.kb_disorders_files / the comorbidity file list, instead of looping just validate "$f" / just validate-comorbidity "$f" per file.
    3. Confirm linkml-reference-validator's installed/pinned version supports multi-file validate data (bump pyproject.toml past >=0.1.8 to >=0.2.0 if needed, per Speed up validate-all: batch the per-file validation loop (multi-file now supported by all three validators) #4448), and add/keep a strict-YAML-parse guard test in tests/test_data.py if not already present, to catch ruamel CParser regressions (flow-style CURIE lists, duplicate keys) across all kb/**/*.yaml.
    4. Keep the existing single-file just validate <file> / just validate-comorbidity <file> recipes intact for local per-file debugging — only the CI loop should switch to batched.
    5. Verify with a local run against a synthetic multi-file change (or against a sampling of existing kb/disorders/*.yaml) that the batched recipe produces equivalent pass/fail results to the per-file loop, then run just qc before opening the PR.

    Link this PR back to both #5088 and #4448 in the description, since it closes out the CI-side follow-up flagged in #4448's last comment.

  2. added a commit that references this issue on Jul 1, 2026
    62d41cd
  3. added a commit that references this issue on Jul 19, 2026
    c4c6a2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions