From 50b6213d5b1a54f62e368ff1f9817f49333869aa Mon Sep 17 00:00:00 2001 From: Steven Kearnes Date: Mon, 27 Jul 2026 20:02:20 -0400 Subject: [PATCH 1/2] Remove the deprecated load_*/save_* aliases The load_*/save_* rename (#818, #833) left forwarding shims that warn and delegate. They shipped in v0.6.30 and have been available through two minor releases; this removes them: * ord_schema.parquet_dataset (whole module, an alias for ord_schema.parquet) * parquet.write_dataset, read_dataset, read_metadata, read_footer, read_reaction * message_helpers.write_message, write_dataset * templating.read_spreadsheet * resolvers.name_resolve Nothing in ord-schema used them. The two guides that named write_message and name_resolve now name save_message and resolve_name. The module-level shim was the one worth removing soonest: its __getattr__ returns Any, so a type checker accepts any attribute reached through ord_schema.parquet_dataset, including attributes that do not exist. Callers elsewhere: ord-data's convert_to_parquet.py and README (Open-Reaction-Database/ord-data#263) and ord-interface's editor server (read_spreadsheet, name_resolve). ord-interface pins ord-schema<0.9, so it is insulated until it widens that bound. Co-Authored-By: Claude Opus 5 (1M context) --- docs/guides/compound_identifiers.rst | 4 +- docs/guides/templates.rst | 2 +- ord_schema/message_helpers.py | 31 +------------- ord_schema/parquet.py | 63 ---------------------------- ord_schema/parquet_dataset.py | 34 --------------- ord_schema/resolvers.py | 11 ----- ord_schema/templating.py | 15 ------- 7 files changed, 4 insertions(+), 156 deletions(-) delete mode 100644 ord_schema/parquet_dataset.py diff --git a/docs/guides/compound_identifiers.rst b/docs/guides/compound_identifiers.rst index da756a91a..8557d849f 100644 --- a/docs/guides/compound_identifiers.rst +++ b/docs/guides/compound_identifiers.rst @@ -80,7 +80,7 @@ Look Them Up ############### The `ORD Reaction Editor `__ has a look up function which can -be used to add chemicals by name. The `name_resolve function `__ +be used to add chemicals by name. The `resolve_name function `__ uses the PubChem and OPSIN APIs to look up names and returns a SMILES string when it is available. For looking up identifiers of organic compounds the following online services can be useful: @@ -97,7 +97,7 @@ For looking up identifiers of organic compounds the following online services ca websites will also report the SMILES in this style. Please refer to :ref:`dative-bonding` below for a recommended workflow for generating SMILES strings which include dative bonding. -Lists of names can be programmatically looked up using the ORD `name_resolve function `__ +Lists of names can be programmatically looked up using the ORD `resolve_name function `__ in Python. diff --git a/docs/guides/templates.rst b/docs/guides/templates.rst index a3c0aa76b..3a699d127 100644 --- a/docs/guides/templates.rst +++ b/docs/guides/templates.rst @@ -26,7 +26,7 @@ Step 1: Create a template reaction See the Python examples `here `_ for how to construct reactions programmatically. After creating a template reaction, - save it as a pbtxt file using `message_helpers.write_message `_. + save it as a pbtxt file using `message_helpers.save_message `_. Here's an `example reaction `_. diff --git a/ord_schema/message_helpers.py b/ord_schema/message_helpers.py index e46d78ba5..d0cc4fbe8 100644 --- a/ord_schema/message_helpers.py +++ b/ord_schema/message_helpers.py @@ -36,7 +36,7 @@ import ord_schema from ord_schema import atomic_io, units -from ord_schema.proto import dataset_pb2, reaction_pb2 +from ord_schema.proto import reaction_pb2 _COMPOUND_IDENTIFIER_LOADERS = { reaction_pb2.CompoundIdentifier.SMILES: Chem.MolFromSmiles, @@ -1086,32 +1086,3 @@ def parse_doi(doi: str) -> str: if not match: raise ValueError(f"could not parse DOI: {doi}") return match.group(1) - - -# Deprecated aliases, kept for backwards compatibility after the load_*/save_* -# rename. Remove in a future minor release. -def write_message( - message: ord_schema.Message, filename: str | os.PathLike[str] -) -> None: - """Deprecated alias for :func:`save_message`.""" - warnings.warn( - "message_helpers.write_message is deprecated; use save_message instead.", - DeprecationWarning, - stacklevel=2, - ) - return save_message(message, filename) - - -def write_dataset( - dataset: dataset_pb2.Dataset, filename: str | os.PathLike[str] -) -> None: - """Deprecated alias for :func:`ord_schema.datasets.save_dataset`.""" - from ord_schema import datasets # noqa: PLC0415 - - warnings.warn( - "message_helpers.write_dataset is deprecated; " - "use ord_schema.datasets.save_dataset instead.", - DeprecationWarning, - stacklevel=2, - ) - datasets.save_dataset(dataset, filename) diff --git a/ord_schema/parquet.py b/ord_schema/parquet.py index 52e57eba5..bbff1e2bf 100644 --- a/ord_schema/parquet.py +++ b/ord_schema/parquet.py @@ -32,7 +32,6 @@ import os import pathlib import tempfile -import warnings from collections.abc import Iterable, Iterator from types import TracebackType from typing import Self @@ -545,65 +544,3 @@ def _get(key: str) -> str | None: if dataset_id: dataset.dataset_id = dataset_id return dataset - - -# Deprecated aliases, kept for backwards compatibility after the load_*/save_* -# rename. Remove in a future minor release. -def write_dataset( - dataset: dataset_pb2.Dataset, - path: str | os.PathLike[str], - *, - compression: str = "zstd", - row_group_size: int = 1000, -) -> None: - """Deprecated alias for :func:`save_dataset`.""" - warnings.warn( - "parquet.write_dataset is deprecated; use save_dataset instead.", - DeprecationWarning, - stacklevel=2, - ) - return save_dataset( - dataset, path, compression=compression, row_group_size=row_group_size - ) - - -def read_dataset(path: str | os.PathLike[str]) -> dataset_pb2.Dataset: - """Deprecated alias for :func:`load_dataset`.""" - warnings.warn( - "parquet.read_dataset is deprecated; use load_dataset instead.", - DeprecationWarning, - stacklevel=2, - ) - return load_dataset(path) - - -def read_metadata(path: str | os.PathLike[str]) -> dataset_pb2.Dataset: - """Deprecated alias for :func:`load_metadata`.""" - warnings.warn( - "parquet.read_metadata is deprecated; use load_metadata instead.", - DeprecationWarning, - stacklevel=2, - ) - return load_metadata(path) - - -def read_footer(path: str | os.PathLike[str]) -> ParquetFooter: - """Deprecated alias for :func:`load_footer`.""" - warnings.warn( - "parquet.read_footer is deprecated; use load_footer instead.", - DeprecationWarning, - stacklevel=2, - ) - return load_footer(path) - - -def read_reaction( - path: str | os.PathLike[str], reaction_id: str -) -> reaction_pb2.Reaction: - """Deprecated alias for :func:`load_reaction`.""" - warnings.warn( - "parquet.read_reaction is deprecated; use load_reaction instead.", - DeprecationWarning, - stacklevel=2, - ) - return load_reaction(path, reaction_id) diff --git a/ord_schema/parquet_dataset.py b/ord_schema/parquet_dataset.py deleted file mode 100644 index 2970ee58c..000000000 --- a/ord_schema/parquet_dataset.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2026 Open Reaction Database Project Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Deprecated alias module for :mod:`ord_schema.parquet`. - -``ord_schema.parquet_dataset`` was renamed to ``ord_schema.parquet``. This module -forwards attribute access to the new module for backwards compatibility and will be -removed in a future minor release. -""" - -import warnings -from typing import Any - -from ord_schema import parquet - - -def __getattr__(name: str) -> Any: - warnings.warn( - "ord_schema.parquet_dataset was renamed to ord_schema.parquet; " - "update your imports.", - DeprecationWarning, - stacklevel=2, - ) - return getattr(parquet, name) diff --git a/ord_schema/resolvers.py b/ord_schema/resolvers.py index dd3ed4283..4f4907813 100644 --- a/ord_schema/resolvers.py +++ b/ord_schema/resolvers.py @@ -17,7 +17,6 @@ import urllib.error import urllib.parse import urllib.request -import warnings from rdkit import Chem @@ -213,13 +212,3 @@ def resolve_input(input_string: str) -> reaction_pb2.ReactionInput: "NCI/CADD CIR": _cactus_resolve, "OPSIN": _opsin_resolve, } - - -def name_resolve(*args: str, **kwargs: str) -> tuple[str, str]: - """Deprecated alias for :func:`resolve_name`.""" - warnings.warn( - "resolvers.name_resolve is deprecated; use resolve_name instead.", - DeprecationWarning, - stacklevel=2, - ) - return resolve_name(*args, **kwargs) diff --git a/ord_schema/templating.py b/ord_schema/templating.py index 3e7f78090..20a14eb2d 100644 --- a/ord_schema/templating.py +++ b/ord_schema/templating.py @@ -20,7 +20,6 @@ import pathlib import re -import warnings from collections.abc import Mapping from typing import BinaryIO @@ -176,17 +175,3 @@ def generate_dataset( reactions.append(reaction) return dataset_pb2.Dataset(name=name, description=description, reactions=reactions) - - -# Deprecated alias, kept for backwards compatibility after the load_*/save_* -# rename. Remove in a future minor release. -def read_spreadsheet( - file_name_or_buffer: str | BinaryIO, suffix: str | None = None -) -> pd.DataFrame: - """Deprecated alias for :func:`load_spreadsheet`.""" - warnings.warn( - "templating.read_spreadsheet is deprecated; use load_spreadsheet instead.", - DeprecationWarning, - stacklevel=2, - ) - return load_spreadsheet(file_name_or_buffer, suffix) From cb6823a872003cab7ea477ad1b1e4d40aea09618 Mon Sep 17 00:00:00 2001 From: Steven Kearnes Date: Mon, 27 Jul 2026 20:05:38 -0400 Subject: [PATCH 2/2] Remove the deprecated --input CLI aliases validate_dataset.py and build_dataset.py accepted --input as an alias for --input_pattern. ord-data's validation.yml still passes --input, but it invokes these scripts from a pinned ORD_SCHEMA_TAG checkout, so it keeps working until that pin moves and can switch to --input_pattern then. Co-Authored-By: Claude Opus 5 (1M context) --- ord_schema/scripts/build_dataset.py | 3 +-- ord_schema/scripts/validate_dataset.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ord_schema/scripts/build_dataset.py b/ord_schema/scripts/build_dataset.py index 94e01fd26..1152d800f 100644 --- a/ord_schema/scripts/build_dataset.py +++ b/ord_schema/scripts/build_dataset.py @@ -31,9 +31,8 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace: parser = argparse.ArgumentParser(description="Build a Dataset from Reaction protos") parser.add_argument( "--input_pattern", - "--input", required=True, - help="Input pattern for Reaction protos (--input is a deprecated alias)", + help="Input pattern for Reaction protos", ) parser.add_argument( "--output", required=True, help="Output Dataset filename (*.pbtxt)" diff --git a/ord_schema/scripts/validate_dataset.py b/ord_schema/scripts/validate_dataset.py index ee756d97e..6e0cd7609 100644 --- a/ord_schema/scripts/validate_dataset.py +++ b/ord_schema/scripts/validate_dataset.py @@ -103,9 +103,8 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace: parser = argparse.ArgumentParser(description="Validate Dataset protocol buffers") parser.add_argument( "--input_pattern", - "--input", required=True, - help="Input pattern for Dataset protos (--input is a deprecated alias)", + help="Input pattern for Dataset protos", ) parser.add_argument("--filter", default=None, help="Regex filename filter") parser.add_argument(