Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions astroquery/mast/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,8 @@ def get_cloud_uris(self, data_products, include_bucket=True, full_url=False):
"""

if self._cloud_connection is None:
raise AttributeError("Must enable s3 dataset before attempting to query the s3 information")
raise RemoteServiceError('Please enable anonymous cloud access by calling `enable_cloud_dataset` method. '
'See MAST Labs documentation for an example: https://mast-labs.stsci.io/#example-data-access-with-astroquery-observations')

return self._cloud_connection.get_cloud_uri_list(data_products, include_bucket, full_url)

Expand Down Expand Up @@ -784,8 +785,10 @@ def get_cloud_uri(self, data_product, include_bucket=True, full_url=False):
"""

if self._cloud_connection is None:
raise AttributeError("Must enable s3 dataset before attempting to query the s3 information")
raise RemoteServiceError('Please enable anonymous cloud access by calling `enable_cloud_dataset` method. '
'See MAST Labs documentation for an example: https://mast-labs.stsci.io/#example-data-access-with-astroquery-observations')

# Query for product URIs
return self._cloud_connection.get_cloud_uri(data_product, include_bucket, full_url)


Expand Down
32 changes: 32 additions & 0 deletions astroquery/mast/tests/test_mast_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,38 @@ def test_observations_download_file(self, tmpdir):
result = mast.Observations.download_file(uri)
assert result == ('COMPLETE', None, None)

def test_get_cloud_uri(self):
test_obs_id = '25568122'

# get a product list
product = mast.Observations.get_product_list(test_obs_id)[24]

assert len(product) > 0, f'No product found for OBSID {test_obs_id}. Unable to move forward with getting URIs from the cloud.'

# enable access to public AWS S3 bucket
mast.Observations.enable_cloud_dataset()

# get uri
uri = mast.Observations.get_cloud_uri(product)

assert len(uri) > 0, f'Product for OBSID {test_obs_id} was not found in the cloud.'

def test_get_cloud_uris(self):
test_obs_id = '25568122'

# get a product list
products = mast.Observations.get_product_list(test_obs_id)[24:]

assert len(products) > 0, f'No products found for OBSID {test_obs_id}. Unable to move forward with getting URIs from the cloud.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't necessarily write assert messages in the tests, but you're right, they likely don't hurt to have :)


# enable access to public AWS S3 bucket
mast.Observations.enable_cloud_dataset()

# get uris
uris = mast.Observations.get_cloud_uris(products)

assert len(uris) > 0, f'Products for OBSID {test_obs_id} were not found in the cloud.'

######################
# CatalogClass tests #
######################
Expand Down