diff --git a/python/lsst/daf/butler/_registry_shim.py b/python/lsst/daf/butler/_registry_shim.py index 45010c1b83..bec40b2024 100644 --- a/python/lsst/daf/butler/_registry_shim.py +++ b/python/lsst/daf/butler/_registry_shim.py @@ -50,7 +50,6 @@ from .registry._collection_type import CollectionType from .registry._defaults import RegistryDefaults from .registry.queries import DataCoordinateQueryResults, DatasetQueryResults, DimensionRecordQueryResults -from .utils import _DefaultMarker, _Marker if TYPE_CHECKING: from .direct_butler import DirectButler @@ -282,11 +281,10 @@ def queryDatasetTypes( self, expression: Any = ..., *, - components: bool | _Marker = _DefaultMarker, missing: list[str] | None = None, ) -> Iterable[DatasetType]: # Docstring inherited from a base class. - return self._registry.queryDatasetTypes(expression, components=components, missing=missing) + return self._registry.queryDatasetTypes(expression, missing=missing) def queryCollections( self, @@ -310,7 +308,6 @@ def queryDatasets( dataId: DataId | None = None, where: str = "", findFirst: bool = False, - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -323,7 +320,6 @@ def queryDatasets( dataId=dataId, where=where, findFirst=findFirst, - components=components, bind=bind, check=check, **kwargs, @@ -337,7 +333,6 @@ def queryDataIds( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -349,7 +344,6 @@ def queryDataIds( datasets=datasets, collections=collections, where=where, - components=components, bind=bind, check=check, **kwargs, @@ -363,7 +357,6 @@ def queryDimensionRecords( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -375,7 +368,6 @@ def queryDimensionRecords( datasets=datasets, collections=collections, where=where, - components=components, bind=bind, check=check, **kwargs, diff --git a/python/lsst/daf/butler/cli/cmd/commands.py b/python/lsst/daf/butler/cli/cmd/commands.py index 3a1300de93..98810481c6 100644 --- a/python/lsst/daf/butler/cli/cmd/commands.py +++ b/python/lsst/daf/butler/cli/cmd/commands.py @@ -38,7 +38,6 @@ collection_type_option, collections_argument, collections_option, - components_option, confirm_option, dataset_type_option, datasets_option, @@ -440,15 +439,9 @@ def query_collections(*args: Any, **kwargs: Any) -> None: "dataset types to return." ) @verbose_option(help="Include dataset type name, dimensions, and storage class in output.") -@components_option() @options_file_option() def query_dataset_types(*args: Any, **kwargs: Any) -> None: """Get the dataset types in a repository.""" - # Drop the components option. - components = kwargs.pop("components") - if components is not None: - comp_opt_str = "" if components else "no-" - click.echo(f"WARNING: --{comp_opt_str}components option is deprecated and will be removed after v27.") table = script.queryDatasetTypes(*args, **kwargs) if table: table.pprint_all() diff --git a/python/lsst/daf/butler/registry/_registry.py b/python/lsst/daf/butler/registry/_registry.py index f934abc898..f9ee587441 100644 --- a/python/lsst/daf/butler/registry/_registry.py +++ b/python/lsst/daf/butler/registry/_registry.py @@ -1015,7 +1015,6 @@ def queryDatasetTypes( self, expression: Any = ..., *, - components: bool = False, missing: list[str] | None = None, ) -> Iterable[DatasetType]: """Iterate over the dataset types whose names match an expression. @@ -1028,9 +1027,6 @@ def queryDatasetTypes( ``...`` can be used to return all dataset types, and is the default. See :ref:`daf_butler_dataset_type_expressions` for more information. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. missing : `list` of `str`, optional String dataset type names that were explicitly given (i.e. not regular expression patterns) but not found will be appended to this @@ -1114,7 +1110,6 @@ def queryDatasets( dataId: DataId | None = None, where: str = "", findFirst: bool = False, - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -1159,9 +1154,6 @@ def queryDatasets( (according to the order of ``collections`` passed in). If `True`, ``collections`` must not contain regular expressions and may not be ``...``. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. @@ -1227,7 +1219,6 @@ def queryDataIds( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -1269,9 +1260,6 @@ def queryDataIds( any column of a dimension table or (as a shortcut for the primary key column of a dimension table) dimension name. See :ref:`daf_butler_dimension_expressions` for more information. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. @@ -1329,7 +1317,6 @@ def queryDimensionRecords( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -1361,9 +1348,6 @@ def queryDimensionRecords( A string expression similar to a SQL WHERE clause. See `queryDataIds` and :ref:`daf_butler_dimension_expressions` for more information. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. diff --git a/python/lsst/daf/butler/registry/queries/_results.py b/python/lsst/daf/butler/registry/queries/_results.py index 4627d246e9..f9f85d4338 100644 --- a/python/lsst/daf/butler/registry/queries/_results.py +++ b/python/lsst/daf/butler/registry/queries/_results.py @@ -321,7 +321,6 @@ def findDatasets( collections: Any, *, findFirst: bool = True, - components: bool = False, ) -> ParentDatasetQueryResults: """Find datasets using the data IDs identified by this query. @@ -341,9 +340,6 @@ def findDatasets( dataset type appears (according to the order of ``collections`` passed in). If `True`, ``collections`` must not contain regular expressions and may not be ``...``. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. Returns ------- diff --git a/python/lsst/daf/butler/registry/sql_registry.py b/python/lsst/daf/butler/registry/sql_registry.py index 6e427e6fb2..b11a614de8 100644 --- a/python/lsst/daf/butler/registry/sql_registry.py +++ b/python/lsst/daf/butler/registry/sql_registry.py @@ -40,7 +40,6 @@ import sqlalchemy from lsst.daf.relation import LeafRelation, Relation from lsst.resources import ResourcePathExpression -from lsst.utils.introspection import find_outside_stacklevel from lsst.utils.iteration import ensure_iterable from .._column_tags import DatasetColumnTag @@ -86,7 +85,7 @@ from ..registry.interfaces import ChainedCollectionRecord, ReadOnlyDatabaseError, RunRecord from ..registry.managers import RegistryManagerInstances, RegistryManagerTypes from ..registry.wildcards import CollectionWildcard, DatasetTypeWildcard -from ..utils import _DefaultMarker, _Marker, transactional +from ..utils import transactional if TYPE_CHECKING: from .._butler_config import ButlerConfig @@ -1705,7 +1704,6 @@ def queryDatasetTypes( self, expression: Any = ..., *, - components: bool | _Marker = _DefaultMarker, missing: list[str] | None = None, ) -> Iterable[DatasetType]: """Iterate over the dataset types whose names match an expression. @@ -1718,9 +1716,6 @@ def queryDatasetTypes( ``...`` can be used to return all dataset types, and is the default. See :ref:`daf_butler_dataset_type_expressions` for more information. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. missing : `list` of `str`, optional String dataset type names that were explicitly given (i.e. not regular expression patterns) but not found will be appended to this @@ -1737,18 +1732,6 @@ def queryDatasetTypes( lsst.daf.butler.registry.DatasetTypeExpressionError Raised when ``expression`` is invalid. """ - if components is not _DefaultMarker: - if components is not False: - raise DatasetTypeError( - "Dataset component queries are no longer supported by Registry. Use " - "DatasetType methods to obtain components from parent dataset types instead." - ) - else: - warnings.warn( - "The components parameter is ignored. It will be removed after v27.", - category=FutureWarning, - stacklevel=find_outside_stacklevel("lsst.daf.butler"), - ) wildcard = DatasetTypeWildcard.from_expression(expression) return self._managers.datasets.resolve_wildcard(wildcard, missing=missing) @@ -1975,7 +1958,6 @@ def queryDatasets( dataId: DataId | None = None, where: str = "", findFirst: bool = False, - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -2020,9 +2002,6 @@ def queryDatasets( (according to the order of ``collections`` passed in). If `True`, ``collections`` must not contain regular expressions and may not be ``...``. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. @@ -2077,18 +2056,6 @@ def queryDatasets( query), and then use multiple (generally much simpler) calls to `queryDatasets` with the returned data IDs passed as constraints. """ - if components is not _DefaultMarker: - if components is not False: - raise DatasetTypeError( - "Dataset component queries are no longer supported by Registry. Use " - "DatasetType methods to obtain components from parent dataset types instead." - ) - else: - warnings.warn( - "The components parameter is ignored. It will be removed after v27.", - category=FutureWarning, - stacklevel=find_outside_stacklevel("lsst.daf.butler"), - ) doomed_by: list[str] = [] data_id = self._standardize_query_data_id_args(dataId, doomed_by=doomed_by, **kwargs) resolved_dataset_types, collection_wildcard = self._standardize_query_dataset_args( @@ -2158,7 +2125,6 @@ def queryDataIds( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -2201,9 +2167,6 @@ def queryDataIds( any column of a dimension table or (as a shortcut for the primary key column of a dimension table) dimension name. See :ref:`daf_butler_dimension_expressions` for more information. - components : `bool`, optional - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. @@ -2250,18 +2213,6 @@ def queryDataIds( lsst.daf.butler.registry.UserExpressionError Raised when ``where`` expression is invalid. """ - if components is not _DefaultMarker: - if components is not False: - raise DatasetTypeError( - "Dataset component queries are no longer supported by Registry. Use " - "DatasetType methods to obtain components from parent dataset types instead." - ) - else: - warnings.warn( - "The components parameter is ignored. It will be removed after v27.", - category=FutureWarning, - stacklevel=find_outside_stacklevel("lsst.daf.butler"), - ) requested_dimensions = self.dimensions.conform(dimensions) doomed_by: list[str] = [] data_id = self._standardize_query_data_id_args(dataId, doomed_by=doomed_by, **kwargs) @@ -2295,7 +2246,6 @@ def queryDimensionRecords( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool | _Marker = _DefaultMarker, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -2327,12 +2277,6 @@ def queryDimensionRecords( A string expression similar to a SQL WHERE clause. See `queryDataIds` and :ref:`daf_butler_dimension_expressions` for more information. - components : `bool`, optional - Whether to apply dataset expressions to components as well. - See `queryDataIds` for more information. - - Must be `False`. Provided only for backwards compatibility. After - v27 this argument will be removed entirely. bind : `~collections.abc.Mapping`, optional Mapping containing literal values that should be injected into the ``where`` expression, keyed by the identifiers they replace. @@ -2370,18 +2314,6 @@ def queryDimensionRecords( lsst.daf.butler.registry.UserExpressionError Raised when ``where`` expression is invalid. """ - if components is not _DefaultMarker: - if components is not False: - raise DatasetTypeError( - "Dataset component queries are no longer supported by Registry. Use " - "DatasetType methods to obtain components from parent dataset types instead." - ) - else: - warnings.warn( - "The components parameter is ignored. It will be removed after v27.", - category=FutureWarning, - stacklevel=find_outside_stacklevel("lsst.daf.butler"), - ) if not isinstance(element, DimensionElement): try: element = self.dimensions[element] diff --git a/python/lsst/daf/butler/tests/hybrid_butler_registry.py b/python/lsst/daf/butler/tests/hybrid_butler_registry.py index 83effc6eca..e838d0a258 100644 --- a/python/lsst/daf/butler/tests/hybrid_butler_registry.py +++ b/python/lsst/daf/butler/tests/hybrid_butler_registry.py @@ -256,7 +256,6 @@ def queryDatasetTypes( self, expression: Any = ..., *, - components: bool = False, missing: list[str] | None = None, ) -> Iterable[DatasetType]: return self._remote.queryDatasetTypes(expression, missing=missing) @@ -282,7 +281,6 @@ def queryDatasets( dataId: DataId | None = None, where: str = "", findFirst: bool = False, - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -307,7 +305,6 @@ def queryDataIds( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -352,7 +349,6 @@ def queryDimensionRecords( datasets: Any = None, collections: CollectionArgType | None = None, where: str = "", - components: bool = False, bind: Mapping[str, Any] | None = None, check: bool = True, **kwargs: Any, @@ -442,11 +438,8 @@ def findDatasets( collections: Any, *, findFirst: bool = True, - components: bool = False, ) -> ParentDatasetQueryResults: - return self._direct().findDatasets( - datasetType, collections, findFirst=findFirst, components=components - ) + return self._direct().findDatasets(datasetType, collections, findFirst=findFirst) def findRelatedDatasets( self, diff --git a/tests/test_testRepo.py b/tests/test_testRepo.py index ccf2c9dca3..22c983bb62 100644 --- a/tests/test_testRepo.py +++ b/tests/test_testRepo.py @@ -171,8 +171,7 @@ def testAddDataIdValue(self): def testAddDatasetType(self): # 1 for StructuredDataNoComponents, 1 for StructuredData (components # not included). - with self.assertWarns(FutureWarning): - self.assertEqual(len(list(self.butler.registry.queryDatasetTypes(components=False))), 2) + self.assertEqual(len(list(self.butler.registry.queryDatasetTypes())), 2) # Testing the DatasetType objects is not practical, because all tests # need a DimensionUniverse. So just check that we have the dataset