Accommodate ORM schema reorg for search/browse queries - #207
Merged
skearnes merged 4 commits intoJul 24, 2026
Merged
Conversation
…uted) ord-schema's upcoming 0.8 release reorganizes the ORM into role-based schemas: the served Reaction proto moves to public.reactions, per-dataset metadata (num_reactions, submitted_at) to public.datasets, and the generated SMILES plus rdkit_*_id links to the derived.* tables (reaction_smiles, compound_smiles, product_compound_smiles). The ord.* schema is now a pure search index. Update the search/browse queries to read from the new locations: - ReactionSmartsQuery / ReactionComponentQuery join ord.reaction (and the compound tables) through the derived SMILES tables to reach the rdkit_*_id links instead of the dropped ord.reaction.rdkit_reaction_id / compound.rdkit_mol_id columns. - fetch_reactions reads proto from public.reactions. - The dataset-stats aggregation joins the derived SMILES tables for the SMILES. - get_datasets / get_dataset join public.datasets for num_reactions / submitted_at. All joins to the derived tables are INNER, mirroring the prior NULL-column filtering: update_derived_tables inserts a derived row only when a SMILES can be generated, so un-derivable entities are dropped exactly as before. Bump the ord-schema pin to >=0.8,<0.9. uv.lock must be regenerated once 0.8.0 is published. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ord-schema 0.8 splits dataset loading into ingest (add_dataset) and derivation (update_derived_data); update the test-postgres helper to call both, mirroring the ord-schema ORM conftest and preserving the rdkit-cartridge gating. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0.8.0 is now published, so resolve the >=0.8,<0.9 pin against it (drops the stale 0.7.1 lock) and pull in uuid6, the new transitive dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
skearnes
marked this pull request as ready for review
July 24, 2026 02:44
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.
Summary
ord-schema's 0.8.0 release reorganizes the ORM into role-based schemas (open-reaction-database/ord-schema#859) and splits dataset loading into separate ingest and derivation stages (open-reaction-database/ord-schema#860, open-reaction-database/ord-schema#861):
public.reactions— the servedReactionproto payload, keyed byreaction_id(moved offord.reaction.proto).public.datasets— per-dataset metadatanum_reactions/submitted_at(moved offord.dataset).derived.*— generated SMILES +rdkit_*_idlinks:reaction_smiles,compound_smiles,product_compound_smiles(moved offord.reaction/ord.compound/ord.product_compound).ord.*— now a pure search index (decomposed message tables only).add_dataset/add_parquet_datasetingestord.*+public.*, andupdate_derived_datapopulates thederived.*SMILES / RDKit links / reaction classes.This PR updates the search/browse queries to read from the new locations and updates the test-fixture loader to the two-stage API.
Changes
ReactionSmartsQuery/ReactionComponentQuery(queries.py) — join throughderived.reaction_smiles/derived.compound_smiles/derived.product_compound_smilesto reach therdkit_*_idlinks, replacing the droppedord.reaction.rdkit_reaction_id/compound.rdkit_mol_idcolumns.fetch_reactions— readsprotofrompublic.reactions._fetch_dataset_most_used_smiles— joins the derived SMILES tables for thesmilescolumn (newsmiles_table/smiles_foreign_keyparams).get_datasets/get_dataset(search.py) — joinpublic.datasetsfornum_reactions/submitted_at.setup_test_postgres(testing.py) — the removedadd_dataset(..., rdkit_cartridge=...)keyword is gone; ingest withadd_dataset(dataset, session)then derive withupdate_derived_data(dataset.dataset_id, session, rdkit_cartridge=...), mirroring the ord-schema ORM conftest and preserving the rdkit-cartridge gating.queries_test.py— the_max_similaritieshelper mirrors_mols_join, updated to the same derived-table joins.ord-schema[orm]>=0.8,<0.9.Reaction classes (ord-schema#854)
No changes needed: ord-interface does not read the reaction class/name fields anywhere (no query, search, or frontend reference), so #854 — and its move to
derived.reaction_classesin #859 — is transparent here.Correctness note
All joins to the
derived.*tables are INNER, which preserves the prior NULL-column filtering:update_derived_tablesinserts a derived row only when a SMILES can be generated, so un-derivable entities are dropped exactly as the oldrdkit_*_id IS NULL/smiles IS NOT NULLpaths did. The API response shapes (DatasetInfo,QueryResult) are unchanged, so no frontend changes are needed.Release status ✅
ord-schema 0.8.0 is published, so this is unblocked:
mainmerged in anduv.lockregenerated (uv lock):ord-schema0.7.1 → 0.8.0, plus the newuuid6transitive dependency.ty checkpre-commit hook — previously skipped because it could not resolve>=0.8— now passes, along withruff check,ruff format, andaddlicense.🤖 Generated with Claude Code
Greptile Summary
Updates the interface for the ord-schema 0.8 ORM reorganization.
derived.*tables.public.*.Confidence Score: 5/5
The PR appears safe to merge because no blocking failures remain within the follow-up review scope.
No blocking failures remain.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR API[Search and browse API] --> IDX[ord.* search index] IDX --> DER[derived.* SMILES and RDKit links] IDX --> PUB[public.reactions and public.datasets] LOAD[Fixture loader] --> INGEST[add_dataset] INGEST --> DERIVE[update_derived_data] DERIVE --> DERReviews (2): Last reviewed commit: "Regenerate uv.lock for ord-schema 0.8.0" | Re-trigger Greptile