Skip to content

Commit

Permalink
Adapting changes to support GALEX cloud products. Error handling upda…
Browse files Browse the repository at this point in the history
…tes.
  • Loading branch information
jaymedina committed Jul 11, 2023
1 parent 39d7e4e commit 8d87d84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 7 additions & 7 deletions astroquery/mast/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from astropy.utils.console import ProgressBarOrSpinner
from astropy.utils.exceptions import AstropyDeprecationWarning

from ..exceptions import NoResultsWarning
from ..exceptions import NoResultsWarning, InvalidQueryError

from . import utils

Expand Down Expand Up @@ -110,7 +110,12 @@ def get_cloud_uri(self, data_product, include_bucket=True, full_url=False):
"""

uri_list = self.get_cloud_uri_list(data_product, include_bucket=include_bucket, full_url=full_url)
return uri_list[0]

# Making sure we got at least 1 URI from the query above.
if len(uri_list) == 0:
raise InvalidQueryError("No products found on the cloud for this query.")
else:
return uri_list[0]

def get_cloud_uri_list(self, data_products, include_bucket=True, full_url=False):
"""
Expand Down Expand Up @@ -142,14 +147,9 @@ def get_cloud_uri_list(self, data_products, include_bucket=True, full_url=False)

uri_list = []
for path in paths:

if path is None:
uri_list.append(None)
elif 'galex' in path:
path = path.lstrip("/mast/")
else:
path = path.lstrip("/")

try:
# Use `head_object` to verify that the product is available on S3 (not all products are)
s3_client.head_object(Bucket=self.pubdata_bucket, Key=path)
Expand Down
11 changes: 10 additions & 1 deletion astroquery/mast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def mast_relative_path(mast_uri):
{"uri": chunk})
json_response = response.json()
for uri in chunk:
result.append(json_response.get(uri[1])["path"])
path = json_response.get(uri[1])["path"]
if 'galex' in path:
path = path.lstrip("/mast/")
else:
path = path.lstrip("/")
result.append(path)

# If the input was a single URI string, we return a single string
if isinstance(mast_uri, str):
Expand All @@ -195,3 +200,7 @@ def _split_list_into_chunks(input_list, chunk_size):
"""Helper function for `mast_relative_path`."""
for idx in range(0, len(input_list), chunk_size):
yield input_list[idx:idx + chunk_size]


def mast_path_strip(path, mission):
"""Helper function to"""

0 comments on commit 8d87d84

Please sign in to comment.