You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All notable changes to this project will be documented in this file.
4
+
5
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+
## [Unreleased]
8
+
9
+
### Added
10
+
-`OntologyLoaderController(mode=...)` kwarg accepting `'meticulous'` (default) or `'fast-initial'`.
11
+
-`meticulous` preserves 0.2.x behavior exactly: pure linkml-store, per-item upsert, force-refresh of the pystow cache, TSV reports written to `report_directory`.
12
+
-`fast-initial` is the new maximum-throughput first-time-install path: raw pymongo `insert_many(ordered=False)`, no pre-read, no upsert, no report tracking, no TSV writes. Reuses the pystow cache if present.
13
+
-`OntologyLoaderController(closure=...)` kwarg accepting a string or list. Values: `combined` (default), `isa`, `partof`, `all` (exclusive shorthand for combined+isa+partof), `none` (exclusive — emit no ancestry closure).
14
+
-`OntologyLoaderController(report_directory=...)` kwarg — renamed from `output_directory`.
15
+
-`OntologyLoaderController(source_ontology=...)` now accepts a list of strings as well as a single string. Multiple ontologies are processed sequentially in the given order; failure on one halts the run.
16
+
- New CLI surface — four flags total: `--source-ontology` (repeatable, required), `--report-directory`, `--mode`, `--closure` (repeatable).
17
+
-`MongoDBLoader.insert_ontology_data_fast_initial(...)` — the raw-pymongo write method used by `mode='fast-initial'`.
18
+
-`OntologyProcessor(force_refresh=...)` constructor kwarg — `True` (default) preserves 0.2.x cache-wiping behavior; `False` reuses the cached pystow artifact when present.
19
+
20
+
### Changed
21
+
-`OntologyProcessor.get_relations_closure()` signature: `predicates=` removed in favor of `closure=` (string or list of strings). The old hardcoded ancestry-relation name (`entailed_isa_partof_closure`) is now selected per-closure: `entailed_isa_partof_closure`, `entailed_isa_closure`, or `entailed_partof_closure`.
22
+
- CLI no longer takes `--generate-reports`. Equivalents under the new design:
23
+
- Old `--generate-reports true` (the implicit default) → new `--mode meticulous` (the default).
24
+
- Old `--generate-reports false` → new `--mode fast-initial`.
25
+
26
+
### Deprecated
27
+
-`OntologyLoaderController(output_directory=...)` — use `report_directory=` instead. The old kwarg is an alias and emits `DeprecationWarning`. Passing both raises `ValueError`.
28
+
-`OntologyLoaderController(generate_reports=True)` — no-op with `DeprecationWarning`. (True was always the default.)
29
+
-`OntologyLoaderController(generate_reports=False)` — maps to `mode='fast-initial'` with `DeprecationWarning`. If `mode` was also passed and isn't `'meticulous'`, raises `ValueError`.
30
+
31
+
### Removed
32
+
- (nothing removed in this release — all 0.2.x kwargs continue to work as deprecated aliases. Removal slated for the next major release after downstream callers — notably the `nmdc-runtime` Dagster job — migrate.)
33
+
34
+
### Migration
35
+
36
+
The exact 0.2.x call site in `nmdc-runtime`'s Dagster op (`nmdc_runtime/site/ops.py`, `load_ontology`) — `OntologyLoaderController(source_ontology=str, output_directory=str, generate_reports=True, mongo_client=..., db_name=...)` — runs **unchanged** under this release. Two `DeprecationWarning` lines appear in the Dagster logs as a nudge to update.
37
+
38
+
To migrate when convenient:
39
+
40
+
```python
41
+
# 0.2.x
42
+
OntologyLoaderController(
43
+
source_ontology="envo",
44
+
output_directory="/tmp/ontology_reports",
45
+
generate_reports=True,
46
+
mongo_client=client,
47
+
db_name="nmdc",
48
+
)
49
+
50
+
# 0.3.0+
51
+
OntologyLoaderController(
52
+
source_ontology="envo", # or ["envo", "po", "uberon"]
53
+
report_directory="/tmp/ontology_reports",
54
+
mode="meticulous", # default; or "fast-initial"
55
+
closure="combined", # default; or "isa", "partof", "all", "none", or a list
Copy file name to clipboardExpand all lines: README.md
+75-31Lines changed: 75 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,13 +75,36 @@ The Docker container networking uses container names (like 'mongo') for internal
75
75
```
76
76
77
77
#### Command line
78
+
78
79
```bash
79
80
% poetry install
80
81
% poetry run ontology_loader --help
81
-
% poetry run ontology_loader --source-ontology "envo"
82
-
% poetry run ontology_loader --source-ontology "uberon"
82
+
% poetry run ontology_loader --source-ontology envo
83
+
% poetry run ontology_loader --source-ontology envo --source-ontology po --source-ontology uberon
83
84
```
84
85
86
+
Four flags:
87
+
88
+
- `--source-ontology <name>` — required, repeatable. Lowercase prefix (envo, po, uberon, ncbitaxon, …). Multiple ontologies are processed sequentially in the given order.
89
+
- `--report-directory <dir>` — TSV report destination (only used in`meticulous` mode). Defaults to a fresh temp directory.
90
+
- `--mode {meticulous|fast-initial}` — default `meticulous`. See "Modes" below.
91
+
- `--closure {combined|isa|partof|all|none}` — default `combined`. Repeatable; values combine. `all` and `none` are exclusive.
92
+
93
+
##### Modes
94
+
95
+
- **`meticulous`** (default): Preserves 0.2.x behavior — pure linkml-store, per-item upsert, force-refresh of the pystow cache on every run, TSV reports (`ontology_updates.tsv`, `ontology_inserts.tsv`, `ontology_relation_inserts.tsv`) written to `--report-directory`. Use this for incremental updates of an already-loaded ontology.
96
+
- **`fast-initial`**: Maximum-throughput first-time install. Raw pymongo `insert_many(ordered=False)`, no upsert, no pre-read, no report tracking, no TSV writes. Reuses the pystow cache if present (downloads only when missing). Use this when the target collections are empty or duplicate-key errors are acceptable. Expected ~3-5x faster than `meticulous` on large ontologies (e.g. NCBITaxon's 2.7M classes + 54.7M relations).
# Pass the client and database name to OntologyLoaderController
127
-
loader = OntologyLoaderController(
166
+
OntologyLoaderController(
128
167
source_ontology="envo",
129
-
output_directory=tempfile.gettempdir(),
130
-
generate_reports=True,
131
-
mongo_client=mongo_client, # Pass the existing client
132
-
db_name="nmdc", # Required when passing an existing client
133
-
)
134
-
135
-
# The loader will use the provided client instead of creating a new connection
136
-
loader.run_ontology_loader()
168
+
mode="meticulous",
169
+
mongo_client=mongo_client, # Pass the existing client
170
+
db_name="nmdc", # Required when passing an existing client
171
+
).run_ontology_loader()
137
172
```
138
173
139
-
This approach is particularly useful when:
140
-
- You're running in a job scheduler like Dagster/Dagit
141
-
- You want to reuse an existing connection pool
142
-
- You have custom MongoDB connection settings that are managed externally
143
-
- You need to use a connection with specific authentication or configuration
174
+
> **Note**: When passing an existing MongoDB client, you must also provide `db_name`. The database name cannot be auto-determined from a MongoClient instance.
175
+
176
+
#### Migrating from 0.2.x
177
+
178
+
The 0.2.x constructor signature (`source_ontology`, `output_directory`, `generate_reports`, `mongo_client`, `db_name`) continues to work as deprecated aliases. The exact call site in nmdc-runtime's Dagster `load_ontology` op runs unchanged under 0.3.0; two `DeprecationWarning` lines appear in the logs as a nudge.
179
+
180
+
| old kwarg | new kwarg | behavior |
181
+
|---|---|---|
182
+
|`source_ontology=<str>`|`source_ontology=<str \| list[str]>`| unchanged; now also accepts a list |
183
+
|`output_directory=<str>`|`report_directory=<str>`| renamed; old kwarg works as alias with `DeprecationWarning`. Passing both raises. |
184
+
|`generate_reports=True`| (gone — implicit) | no-op with `DeprecationWarning` (True was always the default) |
185
+
|`generate_reports=False`|`mode='fast-initial'`| mapped with `DeprecationWarning`. If `mode` was also passed and isn't `'meticulous'`, raises. |
> **Note**: When passing an existing MongoDB client, you must also provide the `db_name` parameter to specify which database to use. This is required as the database name cannot be automatically determined from a MongoDB client instance.
189
+
See `CHANGELOG.md` for the full release note and a side-by-side migration code sample.
0 commit comments