Skip to content

Commit

Permalink
[DM-41830] Go to a simpler refactor about the labels
Browse files Browse the repository at this point in the history
  • Loading branch information
cbanek committed Dec 11, 2023
1 parent 37297bc commit 83f6a7a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 45 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
kubernetes
maproxy
notebook
pyvo
pyvo @ git+https://github.com/astropy/pyvo.git@7682a1809cb2169cc2ffd9313feb6a4abd7f7e37
requests
tornado

Expand Down
2 changes: 0 additions & 2 deletions src/lsst/rsp/catalog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import warnings
from typing import Optional

import pyvo
from deprecated import deprecated
Expand Down
38 changes: 2 additions & 36 deletions src/lsst/rsp/service.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
import os

import pyvo
from pyvo.dal import SIA2Service

from .utils import get_pyvo_auth, get_service_url


LSST_CLOUD = [
"https://data.lsst.cloud",
"https://data-int.lsst.cloud",
"https://data-dev.lsst.cloud"
]

USDF = [
"https://usdf-rsp.slac.stanford.edu/",
"https://usdf-rsp-dev.slac.stanford.edu/"
]


def get_siav2_service(*args: str) -> SIA2Service:
def get_siav2_service(label: str) -> SIA2Service:
"""Return a configured SIA2Service object that is ready to use."""
fqdn = os.environ["EXTERNAL_INSTANCE_URL"]

if len(args) == 0:
# Use the default for each environment
if fqdn in LSST_CLOUD:
label = "dp0.2"
elif fqdn in USDF:
label = "latiss"
else:
raise Exception("Unknown environment" + fqdn)
else:
label = args[0]

# If a label is passed, check that.
if label not in ["dp0.2", "latiss"]:
raise Exception(label + " is not a valid siav2 label")

if label == "latiss" and fqdn not in USDF:
raise Exception(label + " data not available at your location")
if label == "dp0.2" and fqdn not in LSST_CLOUD:
if label != "staff":
raise Exception(label + " data not available at your location")

# No matter what, we've only got one sia server per environment
Expand Down
8 changes: 2 additions & 6 deletions src/lsst/rsp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pyvo.auth.authsession
import requests


_NO_K8S = False

try:
Expand Down Expand Up @@ -56,7 +55,7 @@ def get_hostname() -> str:
return os.environ.get("HOSTNAME") or "localhost"


def get_service_url(name: str, env_name=None) -> str:
def get_service_url(name: str, env_name: Optional[str] = None) -> str:
if not env_name:
env_name = name.upper()

Expand Down Expand Up @@ -129,10 +128,7 @@ def jupyter_proxy_url(port: Optional[int] = None) -> str:
full_url = urllib.parse.urljoin(user_url, proxy_url_path)
return full_url

# The type: ignore is needed because the alternate form of notebook_url
# (https://docs.bokeh.org/en/latest/docs/reference/io.html#bokeh.io.show)
# isn't in bokeh's type hints.
bokeh.io.show(obj=obj, notebook_url=jupyter_proxy_url) # type:ignore
bokeh.io.show(obj=obj, notebook_url=jupyter_proxy_url)


def get_pod() -> Optional[client.V1Pod]:
Expand Down

0 comments on commit 83f6a7a

Please sign in to comment.