-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from lsst-dm/tickets/DM-48282
DM-48282: Use daf_butler subclass for SIAv2Handler with entry point
- Loading branch information
Showing
9 changed files
with
270 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# dax_obscore | ||
|
||
Tools to generate ObsCore data for LSST processed images using Butler Gen 3. | ||
[![pypi](https://img.shields.io/pypi/v/lsst-dax-obscore.svg)](https://pypi.org/project/lsst-dax-obscore/) | ||
[![codecov](https://codecov.io/gh/lsst-dm/dax_obscore/graph/badge.svg?token=TI73D2SG4S)](https://codecov.io/gh/lsst-dm/dax_obscore) | ||
|
||
Tools to generate [IVOA ObsCore](https://www.ivoa.net/documents/ObsCore/) data and process [IVOA SIAv2](https://www.ivoa.net/documents/SIA/) queries for data stored in a Butler repository. | ||
|
||
* [Rubin Observatory Data Butler](https://github.com/lsst/daf_butler) | ||
* [Overview of SIAv2 implementation](https://doi.org/10.48550/arXiv.2501.00544) | ||
|
||
PyPI: [lsst-dax-obscore](https://pypi.org/project/lsst-dax-obscore/) |
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
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,73 @@ | ||
# This file is part of dax_obscore. | ||
# | ||
# 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 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__ = ["get_siav2_handler"] | ||
|
||
from importlib.metadata import EntryPoint, entry_points | ||
from typing import TYPE_CHECKING | ||
|
||
from lsst.utils.introspection import get_full_type_name | ||
|
||
if TYPE_CHECKING: | ||
from .siav2 import SIAv2Handler | ||
|
||
|
||
def _get_siav2_entry_points() -> dict[str, EntryPoint]: | ||
plugins = entry_points(group="dax_obscore.siav2") | ||
return {p.name: p for p in plugins} | ||
|
||
|
||
def get_siav2_handler(namespace: str) -> type[SIAv2Handler]: | ||
"""Select the correct handler for this universe namespace. | ||
Parameters | ||
---------- | ||
namespace : `str` | ||
The butler dimension universe namespace. | ||
Returns | ||
------- | ||
handler : `type` [ `lsst.dax.obscore.siav2.SIAv2Handler` ] | ||
The class of handler suitable for this namespace. | ||
""" | ||
plugins = _get_siav2_entry_points() | ||
entry_point = plugins.get(namespace) | ||
if entry_point is None: | ||
known = ", ".join(plugins.keys()) | ||
raise RuntimeError( | ||
f"Unable to find suitable SIAv2 Handler for namespace {namespace} [do understand: {known}]" | ||
) | ||
func = entry_point.load() | ||
handler_type = func() | ||
|
||
# Check that we have the right type. This has to be a deferred load but | ||
# the code should already be loaded at this point. | ||
from .siav2 import SIAv2Handler | ||
|
||
if not issubclass(handler_type, SIAv2Handler): | ||
raise TypeError( | ||
f"Entry point for universe {namespace} did not return SIAv2Handler. " | ||
f"Returned {get_full_type_name(handler_type)}" | ||
) | ||
|
||
return func() |
Oops, something went wrong.