From aec539fe430cba558de7ca9ab08f1f97579f50b4 Mon Sep 17 00:00:00 2001 From: Christine Banek Date: Mon, 11 Dec 2023 16:51:30 -0700 Subject: [PATCH] [DM-41830] Add in get_datalink_result --- src/lsst/rsp/__init__.py | 3 +++ src/lsst/rsp/service.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/lsst/rsp/__init__.py b/src/lsst/rsp/__init__.py index be2e6b9..b263515 100644 --- a/src/lsst/rsp/__init__.py +++ b/src/lsst/rsp/__init__.py @@ -12,6 +12,7 @@ ) from .forwarder import Forwarder from .log import IPythonHandler, forward_lsst_log +from .service import get_datalink_result, get_siav2_service from .utils import ( format_bytes, get_access_token, @@ -40,10 +41,12 @@ "forward_lsst_log", "get_access_token", "get_catalog", + "get_datalink_result", "get_digest", "get_node", "get_pod", "get_tap_service", + "get_siav2_service", "get_obstap_service", "retrieve_query", "get_hostname", diff --git a/src/lsst/rsp/service.py b/src/lsst/rsp/service.py index c194a7d..466ebff 100644 --- a/src/lsst/rsp/service.py +++ b/src/lsst/rsp/service.py @@ -1,8 +1,17 @@ from pyvo.dal import SIA2Service +from pyvo.dal.adhoc import DatalinkResults +from pyvo.dal.sia2 import ObsCoreRecord from .utils import get_pyvo_auth, get_service_url +def get_datalink_result(result: ObsCoreRecord) -> DatalinkResults: + """Helper function to return the datalink part of the result.""" + return DatalinkResults.from_result_url( + result.getdataurl(), session=get_pyvo_auth() + ) + + def get_siav2_service(label: str) -> SIA2Service: """Return a configured SIA2Service object that is ready to use.""" if label != "staff":