-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on extending butler collections API
- Loading branch information
Showing
5 changed files
with
235 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
94 changes: 94 additions & 0 deletions
94
python/lsst/daf/butler/remote_butler/_remote_butler_collections.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# This file is part of daf_butler. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (http://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This software is dual licensed under the GNU General Public License and also | ||
# under a 3-clause BSD license. Recipients may choose which of these licenses | ||
# to use; please see the files gpl-3.0.txt and/or bsd_license.txt, | ||
# respectively. If you choose the GPL option then the following text applies | ||
# (but note that there is still no warranty even if you opt for BSD instead): | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from __future__ import annotations | ||
|
||
__all__ = ("RemoteButlerCollections",) | ||
|
||
from collections.abc import Iterable, Sequence, Set | ||
|
||
from .._butler_collections import ButlerCollections, CollectionInfo | ||
from .._collection_type import CollectionType | ||
from ._registry import RemoteButlerRegistry | ||
|
||
|
||
class RemoteButlerCollections(ButlerCollections): | ||
"""Implementation of ButlerCollections for RemoteButler. | ||
Parameters | ||
---------- | ||
registry : `~lsst.daf.butler.registry.sql_registry.SqlRegistry` | ||
Registry object used to work with the collections database. | ||
""" | ||
|
||
def __init__(self, registry: RemoteButlerRegistry): | ||
self._registry = registry | ||
|
||
@property | ||
def defaults(self) -> Sequence[str]: | ||
return self._registry.defaults.collections | ||
|
||
def extend_chain(self, parent_collection_name: str, child_collection_names: str | Iterable[str]) -> None: | ||
raise NotImplementedError("Not yet available") | ||
|
||
def prepend_chain(self, parent_collection_name: str, child_collection_names: str | Iterable[str]) -> None: | ||
raise NotImplementedError("Not yet available") | ||
|
||
def redefine_chain( | ||
self, parent_collection_name: str, child_collection_names: str | Iterable[str] | ||
) -> None: | ||
raise NotImplementedError("Not yet available") | ||
|
||
def remove_from_chain( | ||
self, parent_collection_name: str, child_collection_names: str | Iterable[str] | ||
) -> None: | ||
raise NotImplementedError("Not yet available") | ||
|
||
def query( | ||
self, | ||
expression: str | Iterable[str], | ||
collection_types: Set[CollectionType] | CollectionType | None = None, | ||
flatten_chains: bool = False, | ||
include_chains: bool | None = None, | ||
) -> Sequence[str]: | ||
if collection_types is None: | ||
collection_types = CollectionType.all() | ||
return self._registry.queryCollections( | ||
expression, | ||
collectionTypes=collection_types, | ||
flattenChains=flatten_chains, | ||
includeChains=include_chains, | ||
) | ||
|
||
def get_info(self, name: str, include_doc: bool = False, include_parents: bool = False) -> CollectionInfo: | ||
info = self._registry._get_collection_info( | ||
name, include_doc=include_doc, include_parents=include_parents | ||
) | ||
doc = info.doc or "" | ||
children = info.children or () | ||
parents = info.parents or set() | ||
return CollectionInfo(name=name, type=info.type, doc=doc, parents=parents, children=children) | ||
This file contains 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