Skip to content

Commit

Permalink
Remove deprecated components parameter from registry APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Aug 8, 2024
1 parent 427f673 commit 08009dd
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 115 deletions.
10 changes: 1 addition & 9 deletions python/lsst/daf/butler/_registry_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -323,7 +320,6 @@ def queryDatasets(
dataId=dataId,
where=where,
findFirst=findFirst,
components=components,
bind=bind,
check=check,
**kwargs,
Expand All @@ -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,
Expand All @@ -349,7 +344,6 @@ def queryDataIds(
datasets=datasets,
collections=collections,
where=where,
components=components,
bind=bind,
check=check,
**kwargs,
Expand All @@ -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,
Expand All @@ -375,7 +368,6 @@ def queryDimensionRecords(
datasets=datasets,
collections=collections,
where=where,
components=components,
bind=bind,
check=check,
**kwargs,
Expand Down
7 changes: 0 additions & 7 deletions python/lsst/daf/butler/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
collection_type_option,
collections_argument,
collections_option,
components_option,
confirm_option,
dataset_type_option,
datasets_option,
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 0 additions & 16 deletions python/lsst/daf/butler/registry/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions python/lsst/daf/butler/registry/queries/_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
-------
Expand Down
70 changes: 1 addition & 69 deletions python/lsst/daf/butler/registry/sql_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 1 addition & 8 deletions python/lsst/daf/butler/tests/hybrid_butler_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 08009dd

Please sign in to comment.