Skip to content

Commit f23a6e0

Browse files
authored
Merge pull request #70 from lsst-sqre/tickets/DM-49626
DM-49626: Modify get_siav2_service to work with new SIA endpoint
2 parents 2d9a4ca + 5081477 commit f23a6e0

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- Delete the sections that don't apply -->
2+
3+
### Other changes
4+
5+
- Changed get_siav2_service to work with new SIA app and added data_release parameter to it

src/lsst/rsp/service.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Utility functions for IVOA clients."""
22

3+
import os
4+
35
from pyvo.dal import SIA2Service
46
from pyvo.dal.adhoc import DatalinkResults
57
from pyvo.dal.sia2 import ObsCoreRecord
@@ -14,11 +16,29 @@ def get_datalink_result(result: ObsCoreRecord) -> DatalinkResults:
1416
)
1517

1618

17-
def get_siav2_service(label: str) -> SIA2Service:
19+
def get_siav2_service(data_release: str) -> SIA2Service:
1820
"""Construct an `SIA2Service` client."""
19-
if label != "staff":
20-
raise ValueError(label + " data not available at your location")
21+
# data_release determines the Data release, as we may have different
22+
# releases being served from the same server.
23+
24+
label = os.getenv("RSP_SITE_TYPE", None)
25+
26+
# The label variable here corresponds to RSP "kind" (i.e. "telescope",
27+
# "science", "staff")
28+
29+
if label not in {"science", "staff"}:
30+
if label is None:
31+
raise ValueError("RSP_SITE_TYPE environment variable is not set")
32+
raise ValueError(f"{label} data not available at your location")
33+
34+
sia_url = get_service_url(f"sia/{data_release}")
35+
if not sia_url:
36+
raise RuntimeError(
37+
f"Failed to determine service URL for data release: {data_release}"
38+
)
39+
40+
session = get_pyvo_auth()
41+
if session:
42+
session.add_security_method_for_url(sia_url + "/query", "lsst-token")
2143

22-
# No matter what, we've only got one sia server per environment
23-
# so for now just do some checking.
24-
return SIA2Service(get_service_url("siav2"), get_pyvo_auth())
44+
return SIA2Service(sia_url, session=session)

src/lsst/rsp/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_pyvo_auth() -> pyvo.auth.authsession.AuthSession | None:
8181
"ssotap": get_service_url("ssotap"),
8282
"consdbtap": get_service_url("consdbtap"),
8383
"live": get_service_url("live"),
84-
"siav2": get_service_url("siav2"),
84+
"sia": get_service_url("sia"),
8585
"cutout": get_service_url("cutout"),
8686
"datalink": get_service_url("datalink"),
8787
}
@@ -94,9 +94,6 @@ def get_pyvo_auth() -> pyvo.auth.authsession.AuthSession | None:
9494
for subpath in ["/sync", "/async", "/tables"]:
9595
auth.add_security_method_for_url(url + subpath, "lsst-token")
9696

97-
elif name == "siav2":
98-
auth.add_security_method_for_url(url + "/query", "lsst-token")
99-
10097
return auth
10198

10299

0 commit comments

Comments
 (0)