Coverage for python/lsst/daf/butler/registry/queries/_sql_query_backend.py: 62%
24 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-07 02:47 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-07 02:47 -0700
1# This file is part of daf_butler.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21from __future__ import annotations
23__all__ = ("SqlQueryBackend",)
25from collections.abc import Set
26from typing import TYPE_CHECKING, Any
28from .._collectionType import CollectionType
29from ._query_backend import QueryBackend
31if TYPE_CHECKING: 31 ↛ 32line 31 didn't jump to line 32, because the condition on line 31 was never true
32 from ...core import DatasetType, DimensionUniverse
33 from ..interfaces import CollectionRecord, Database
34 from ..managers import RegistryManagerInstances
37class SqlQueryBackend(QueryBackend):
38 """An implementation of `QueryBackend` for `SqlRegistry`.
40 Parameters
41 ----------
42 db : `Database`
43 Object that abstracts the database engine.
44 managers : `RegistryManagerInstances`
45 Struct containing the manager objects that back a `SqlRegistry`.
46 """
48 def __init__(
49 self,
50 db: Database,
51 managers: RegistryManagerInstances,
52 ):
53 self._db = db
54 self._managers = managers
56 @property
57 def managers(self) -> RegistryManagerInstances:
58 # Docstring inherited.
59 return self._managers
61 @property
62 def universe(self) -> DimensionUniverse:
63 # Docstring inherited.
64 return self._managers.dimensions.universe
66 def resolve_collection_wildcard(
67 self,
68 expression: Any,
69 *,
70 collection_types: Set[CollectionType] = CollectionType.all(),
71 done: set[str] | None = None,
72 flatten_chains: bool = True,
73 include_chains: bool | None = None,
74 ) -> list[CollectionRecord]:
75 # Docstring inherited.
76 return self._managers.collections.resolve_wildcard(
77 expression,
78 collection_types=collection_types,
79 done=done,
80 flatten_chains=flatten_chains,
81 include_chains=include_chains,
82 )
84 def resolve_dataset_type_wildcard(
85 self,
86 expression: Any,
87 components: bool | None = None,
88 missing: list[str] | None = None,
89 explicit_only: bool = False,
90 ) -> dict[DatasetType, list[str | None]]:
91 # Docstring inherited.
92 return self._managers.datasets.resolve_wildcard(expression, components, missing, explicit_only)