ontologies: drop metamodel edges AFTER the biolink:->CURIE remap (fix #602)#603
Merged
Conversation
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>
…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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inpost_process, before_normalize_schemaremaps KGX's meta-predicates from theirbiolink:serialization — KGX emitsbiolink:subPropertyOf/biolink:inverseOf/biolink:type, and_normalize_schemalater remaps them tordfs:subPropertyOf/owl:inverseOf/rdf:type. So the CURIE filter matched nothing.Confirmed by a real
kg transform -s ontologiesrun: it still emitted 252 envo + 75 metpo metamodel edges, and the output edge files carried theknowledge_levelcolumn — proving the early method ran but dropped nothing.Fix
Move the drop into
_normalize_schema, immediately after thebiolink:→rdfs/owl/rdf remap, where predicates are in final CURIE form._add_kgx_metadata_to_edgesreverts to metadata-only. Still single read/write (the drop rides_normalize_schema's existing edge read/write).Verification
_normalize_schemaremap-then-drop) pass; CI-ruff (0.15.22) clean.🤖 Generated with Claude Code