Repository navigation
Conversation
The load_ontology op gains a closure option, passed through to ontology-loader. It defaults to combined, the only closure nmdc-server reads. The three weekly schedules set it to all, so the isa and partof closures are stored alongside combined.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Feature Merge Risk:
|
|
The diff looks fine to me, but I don't know what "closure" means in this context. |
| "output_directory": Field(Noneable(str), default_value=None, is_required=False), | ||
| "generate_reports": Field(bool, default_value=True, is_required=False), | ||
| # Which ancestor closures ontology-loader stores in ontology_relation_set: | ||
| # "combined" (is_a plus part of), "isa", "partof", "all" (all three) or "none". |
There was a problem hiding this comment.
"combined" (is_a plus part of) ...
I don't understand why is_a is spelled with an underscore here, but part of is not. 🤷
There was a problem hiding this comment.
You're right, that was inconsistent. Fixed in b795d58
There was a problem hiding this comment.
🔵 Needs a closer look
The weekly UBERON load roughly doubles to 1.06M relations via per-item upserts, with unmeasured runtime and resource demands requiring human review of production worker capacity and the weekly load window.
No open issues 🎉
What changed in this PR
Adds configurable ancestor closures to the Runtime’s Dagster ontology loader, enabling separate is-a and part-of queries while preserving the combined closure used by the Data Portal.
Changes:
- Adds a
closuresetting that defaults tocombinedfor backward compatibility. - Configures weekly ENVO, UBERON, and PO loads to store all three closures.
- Updates mocked tests to check the default and explicit
allsetting.
| File | Description |
|---|---|
| tests/test_ops/test_load_ontology.py | Checks default and explicit closure forwarding. |
| nmdc_runtime/site/repository.py | Sets the three weekly ontology loads to closure: all. |
| nmdc_runtime/site/ops/ontology.py | Defines, logs, and forwards the closure setting to the loader. |
Review effort: Balanced
|
@eecavanna A closure is the set of a term's ancestors. Before this PR, the weekly loads stored one closure, |
On this branch, I gave the
load_ontologyop aclosuresetting and set it toallin the weekly ENVO, UBERON and PO schedules. Each load then stores a term's "is a kind of" ancestors and its "is part of" ancestors as separate predicates inontology_relation_set, beside the mixed set it stores now. nmdc-server's ENVO ingest reads only the mixed set (https://github.com/microbiomedata/nmdc-server/blob/e8ab95276c5c4c46354e48090048de2240e45a37/nmdc_server/ingest/envo.py#L80), so the Data Portal doesn't change. The separate sets let people ask "is a kind of" questions directly, and give the portal what it needs if we decide its filters should stop following "is part of".Details
ontology-loader 0.5.0, already pinned on main, can write three ancestor predicates:
entailed_isa_partof_closurefollows bothrdfs:subClassOfandBFO:0000050(part of). It is the only one stored now.entailed_isa_closurefollows onlyrdfs:subClassOf.entailed_partof_closurefollowsBFO:0000050, and also therdfs:subClassOfsteps above the whole. Rhizosphere (ENVO:00005801) is part of soil (ENVO:00001998), and soil is a kind of environmental material (ENVO:00010483), so rhizosphere is listed as part of environmental material.The op's
closuresetting defaults tocombined, which writes onlyentailed_isa_partof_closure, so a job that doesn't set it behaves as before.allwrites all three.Relation rows with
all, counted on 2026-11-24 with ontology-loader's own code against the semantic-sql builds (https://semanticsql.berkeleybop.io) cached on my machine:nmdc-server's ingest copies every relation into its Postgres
ontology_relationtable, so that table grows the same way. I haven't timed a weekly UBERON load withall. If it runs too long, UBERON's schedule can go back tocombined, though the rows already written would need deleting by hand.Related issue(s)
Part of #1563, which stays open for NCBITaxon.
This stores the two closures microbiomedata/nmdc-schema#2943 asks for. It needs no schema change.
Whether the portal should use them is microbiomedata/nmdc-server#2449.
After this merges, the pure "is a kind of" query in #1432 should become a find command on
entailed_isa_closurethrough/queries:run, instead of a$graphLookup. I haven't tried that onontology_relation_set.My draft #1562 adds its own
closurefield. I'd rebase it onto this PR once this one merges.Related subsystem(s)
docsdirectory)Testing
I tested these changes on 2026-11-24 with uv on my machine, not the Docker test stack:
tests/test_ops/test_load_ontology.py: both mocked tests pass, and both fail with main'snmdc_runtime/site/ops/ontology.py.validate_run_configaccepts all three schedule configs, each resolving toclosure: all.closure: allloaded ENVO into a throwaway database on a local MongoDB in 4 seconds: 4,366 classes and 76,714 relations, matching the ENVO count above.I didn't run
make testor load UBERON or PO withall.Documentation
docsdirectory)Nothing in
docs/mentionsclosureorload_ontology.Maintainability
study_id: str)# TODOor# FIXMEblackto format all the Python files I created/modifiedThe changed files in
nmdc_runtime/passblack --check.tests/test_ops/test_load_ontology.pywasn't black-formatted on main, and I left it that way to keep the diff small.Summary by CodeRabbit