Accommodate ORM schema reorg for search/browse queries#207
Draft
skearnes wants to merge 2 commits into
Draft
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>
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 upcoming 0.8 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.Blocked on release⚠️
Draft until ord-schema 0.8.0 is published:
uv.lockstill pins 0.7.1 and must be regenerated (uv lock) once 0.8.0 is on PyPI.ty checkpre-commit hook) cannot resolve>=0.8until then; these commits were pushed skipping only thety-checkhook for that reason —ruff check,ruff format, andaddlicenseall pass.🤖 Generated with Claude Code