Skip to content

ontologies: drop metamodel edges AFTER the biolink:->CURIE remap (fix #602)#603

Merged
realmarcin merged 2 commits into
masterfrom
fix/metamodel-drop-after-remap
Jul 21, 2026
Merged

ontologies: drop metamodel edges AFTER the biolink:->CURIE remap (fix #602)#603
realmarcin merged 2 commits into
masterfrom
fix/metamodel-drop-after-remap

Conversation

@realmarcin

Copy link
Copy Markdown
Collaborator

What

Bug fix to #602: the metamodel-edge drop never actually ran on the transform output.

Root cause

The drop was in _add_kgx_metadata_to_edges, which runs early in post_process, before _normalize_schema remaps KGX's meta-predicates from their biolink: serialization — KGX emits biolink:subPropertyOf / biolink:inverseOf / biolink:type, and _normalize_schema later remaps them to rdfs:subPropertyOf / owl:inverseOf / rdf:type. So the CURIE filter matched nothing.

Confirmed by a real kg transform -s ontologies run: it still emitted 252 envo + 75 metpo metamodel edges, and the output edge files carried the knowledge_level column — proving the early method ran but dropped nothing.

Fix

Move the drop into _normalize_schema, immediately after the biolink:→rdfs/owl/rdf remap, where predicates are in final CURIE form. _add_kgx_metadata_to_edges reverts to metadata-only. Still single read/write (the drop rides _normalize_schema's existing edge read/write).

Verification

  • 4 tests (df-helper + _normalize_schema remap-then-drop) pass; CI-ruff (0.15.22) clean.
  • End-to-end on real data: 2,179 metamodel edges removed across the 10 ontology edge outputs (ro 848, uberon 382, mondo 328, envo 252, pato 252, metpo 75, foodon 36, go 4, chebi 1, ec 1).

🤖 Generated with Claude Code

Follow-up bug fix to #602. The metamodel-edge drop was placed in
`_add_kgx_metadata_to_edges`, which runs early in `post_process` — before
`_normalize_schema` remaps KGX's meta-predicates from their `biolink:`
serialization (`biolink:subPropertyOf` / `biolink:inverseOf` / `biolink:type`)
to `rdfs:subPropertyOf` / `owl:inverseOf` / `rdf:type`. So the CURIE filter
matched nothing and the edges survived to the output (confirmed: a full
`kg transform -s ontologies` still emitted 252 envo / 75 metpo metamodel
edges, and the output edge files carried the knowledge_level column proving
the early method ran but dropped nothing).

Move the drop into `_normalize_schema`, immediately after the
biolink:->rdfs/owl/rdf remap, where predicates are in their final CURIE form
and `_drop_metamodel_edges` actually matches. `_add_kgx_metadata_to_edges`
reverts to metadata-only (keeps the low_memory=False read). Still single
read/write (the drop rides `_normalize_schema`'s existing edge read/write).

Test retargeted to `_normalize_schema`, feeding `biolink:`-form predicates to
verify the remap-then-drop sequence. Verified end-to-end on real data: the
drop removes 2,179 metamodel edges across the 10 ontology edge outputs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 21, 2026 00:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…erage (review)

Addresses PR #603 review (all LOW):
- Also normalize bare local-name predicates (subPropertyOf/inverseOf/type)
  to CURIEs in _normalize_schema before the metamodel drop, so a bare token
  landing in `predicate` (not just `relation`) is still caught.
- Restore end-to-end coverage of the reverted _add_kgx_metadata_to_edges:
  assert it adds knowledge_level/agent_type and drops nothing (metamodel
  rows are still biolink:-namespaced at that stage).
- Assert the post-drop column set/order equals edge_header, and cover the
  bare-token predicate path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@realmarcin

Copy link
Copy Markdown
Collaborator Author

Independent review confirmed the fix is correct (drop now runs after the biolink:->CURIE remap in _normalize_schema, which is the last predicate-touching step). Addressed the three LOW items: added belt-and-braces normalization of bare local-name predicates before the drop, restored end-to-end coverage that the reverted _add_kgx_metadata_to_edges adds metadata and drops nothing, and added a column-set/order assertion. 5 tests pass, ruff 0.15.22 clean.

@realmarcin
realmarcin merged commit b0fdfa1 into master Jul 21, 2026
3 checks passed
@realmarcin
realmarcin deleted the fix/metamodel-drop-after-remap branch July 21, 2026 03:36
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.

2 participants