Skip to content

Canonical OWL layout: ROBOT formatter, pre-commit hook and CI check; validator reads XML - #154

Merged
KrishnaTO merged 3 commits into
mainfrom
ontology-formatter
Oct 25, 2026
Merged

KrishnaTO merged 3 commits into
mainfrom
ontology-formatter

Conversation

@KrishnaTO

Copy link
Copy Markdown
Owner

Summary

Project 0 of the ontology modules design (#153). Every ontologies/*.owl is now in one canonical layout, the one ROBOT writes, so the same content always has the same bytes. The app (owlready2), Protégé and scripts can each write the ontology, and a diff shows only what changed.

  • tools/format-owl.sh [--check]
    • Runs robot convert at the release pinned in tools/robot.version (1.9.11; the jar's sha256 is checked).
    • Needs Java 11+.
    • Downloads the jar into .cache/robot/ on first use.
  • ontologies/catalog-v001.xml resolves the ari_uberon import locally, for ROBOT and Protégé.
  • .githooks/pre-commit
    • Formats staged ontologies/*.owl. Install it once with git config core.hooksPath .githooks.
    • Refuses a file that also has unstaged changes.
  • The new OWL format workflow fails a PR whose ontology files are not canonical.
  • .gitattributes keeps *.owl, *.sh and the hooks LF on every platform.
  • validate_mappings.py reads the ontology as XML (expat) instead of matching lines. With --since, an ontology finding counts as new only when its statement (subject, property, value) is new.
  • build_symptom_mapping.py and build_uberon_import.py edit ari_t1d.owl as XML and leave the layout to the formatter.
  • A separate commit re-lays-out ari_t1d.owl and ari_uberon.owl, with no content change.

Verification

  • No content change: robot diff on the reformat commit reports the ontologies identical. owlready2 loads both versions with the same 228 diseases, 2,294 symptoms and all 37,290 property values, and the import resolves.
  • Idempotent: formatting a formatted file changes nothing. The 5 MB file takes about 5–11 s.
  • Validator:
    • The old and new parsers agree on today's file: same diseases, annotations and line numbers. They also agree on the formatted file's values and symptom findings.
    • A deliberately broken symptomConcept is still caught.
    • --since HEAD~1 on the reformat commit reports 0 findings.
  • Builders: both scripts were run against the real release dumps, on the old and on the formatted layout. Formatted afterwards, each reproduces today's file byte for byte.
  • Hook (tested in a throwaway clone): a whole-file XML rewrite with one label changed committed as a 1-line diff, and partial staging was refused.
  • --check: exits 1 on an unformatted file. Under Java 8, format-owl.sh exits with a clear message.

Merge order

This pairs with KrishnaTO/ARI-metadata-manager canonical-owl-format. Once this is on main, the deployed app's line splice can no longer order a publish: it matches nothing in this layout and appends every block. So the cutover goes:

  1. Drain the open edit/* PRs.
  2. Install ROBOT on the server.
  3. Merge this PR.
  4. Deploy the app PR.
  5. Run one test publish.

Each server step needs confirmation at the time. Both this PR and #153 add a changelog entry at the top, so whichever merges second needs a one-line rebase.

🤖 Generated with Claude Code

KrishnaTO and others added 2 commits October 22, 2026 15:35
…logy as XML

Any tool may write the ontology; tools/format-owl.sh (ROBOT 1.9.11, pinned in
tools/robot.version) rewrites it into one layout so identical content has
identical bytes. The pre-commit hook runs it on staged ontologies/*.owl, and the
OWL format workflow fails a PR whose files are not canonical.

The validator and the two notebook builders read and edit the file as XML
instead of by line, because the layout is no longer theirs. Diff scoping of
ontology findings compares statements, not line text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Output of tools/format-owl.sh, nothing else. ROBOT diff reports the
ontologies identical to the previous commit; every later diff to these files
shows only content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KrishnaTO
KrishnaTO merged commit 4ae60a6 into main Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant