Skip to content

Commit

Permalink
Merge pull request #126 from lsst-sitcom/tickets/DM-47269
Browse files Browse the repository at this point in the history
DM-47269:  Change fail behavior of getSite() and fix build breakage
  • Loading branch information
mfisherlevine authored Oct 29, 2024
2 parents 9b2bdd9 + d05a360 commit 83e1902
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 8 additions & 2 deletions python/lsst/summit/utils/butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def makeDefaultButler(
Raises
------
FileNotFoundError
Raised if the butler cannot be created.
Raised if the butler cannot be created, because this is the error
when the DAF_BUTLER_REPOSITORY_INDEX is not set correctly.
"""
SUPPORTED_SITES = [
"summit",
Expand All @@ -186,7 +187,12 @@ def makeDefaultButler(

site = getSite()
if site not in SUPPORTED_SITES:
raise ValueError(f"Default butler creation only supported at sites: {SUPPORTED_SITES}, got {site=}")
# This might look like a slightly weird error to raise, but this is
# the same error that's raised when the DAF_BUTLER_REPOSITORY_INDEX
# isn't set, so it's the most appropriate error to raise here, i.e.
# this is what would be raised if this function was allowed to continue
# only this is a less confusing version of it.
raise FileNotFoundError(f"Default butler creation only available at: {SUPPORTED_SITES}, got {site=}")

summitLike = site in ["summit", "tucson", "base"]
if summitLike:
Expand Down
7 changes: 3 additions & 4 deletions python/lsst/summit/utils/efdUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,9 @@ def makeEfdClient(testing: bool | None = False) -> EfdClient:
if testing:
return EfdClient("usdf_efd")

try:
site = getSite()
except ValueError as e:
raise RuntimeError("Could not create EFD client as the site could not be determined") from e
site = getSite()
if site == "UNKNOWN":
raise RuntimeError("Could not create EFD client as the site could not be determined")

if site == "summit":
return EfdClient("summit_efd")
Expand Down
7 changes: 2 additions & 5 deletions python/lsst/summit/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,8 @@ def getSite() -> str:
One of:
['tucson', 'summit', 'base', 'staff-rsp', 'rubin-devl', 'jenkins',
'usdf-k8s']
If the location cannot be determined "UNKOWN" is returned.
Raises
------
ValueError
Raised if location cannot be determined.
"""
# All nublado instances guarantee that EXTERNAL_URL is set and uniquely
# identifies it.
Expand Down Expand Up @@ -647,7 +644,7 @@ def getSite() -> str:
return "usdf-k8s"

# we have failed
raise ValueError("Location could not be determined")
return "UNKOWN"


def getAltAzFromSkyPosition(
Expand Down

0 comments on commit 83e1902

Please sign in to comment.