Skip to content

Commit 2a27dff

Browse files
authored
Merge pull request #3069 from snbianco/ASB-28015-cloud-error-msg
Bugfix in get_cloud_uri_list, added test case
2 parents 08ff1b8 + d10a28c commit 2a27dff

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

astroquery/mast/cloud.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def get_cloud_uri_list(self, data_products, include_bucket=True, full_url=False)
160160
elif full_url:
161161
path = "http://s3.amazonaws.com/{}/{}".format(self.pubdata_bucket, path)
162162
uri_list.append(path)
163+
else:
164+
uri_list.append(path)
163165
except self.botocore.exceptions.ClientError as e:
164166
if e.response['Error']['Code'] != "404":
165167
raise
@@ -192,7 +194,7 @@ def download_file(self, data_product, local_path, cache=True, verbose=True):
192194
warnings.simplefilter("ignore")
193195
bucket_path = self.get_cloud_uri(data_product, False)
194196
if not bucket_path:
195-
raise Exception("Unable to locate file {}.".format(data_product['productFilename']))
197+
raise Exception("Unable to locate file {}.".format(data_product['dataURI']))
196198

197199
# Ask the webserver (in this case S3) what the expected content length is and use that.
198200
info_lookup = s3_client.head_object(Bucket=self.pubdata_bucket, Key=bucket_path)

astroquery/mast/tests/test_mast_remote.py

+14
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,20 @@ def check_result(result, path):
505505
result = Observations.download_file(uri, local_path=local_path_file)
506506
check_result(result, local_path_file)
507507

508+
@pytest.mark.parametrize("in_uri", [
509+
'mast:HLA/url/cgi-bin/getdata.cgi?download=1&filename=hst_05206_01_wfpc2_f375n_wf_daophot_trm.cat',
510+
'mast:HST/product/u24r0102t_c3m.fits'
511+
])
512+
def test_observations_download_file_cloud(self, tmp_path, in_uri):
513+
pytest.importorskip("boto3")
514+
515+
Observations.enable_cloud_dataset()
516+
517+
filename = Path(in_uri).name
518+
result = Observations.download_file(uri=in_uri, cloud_only=True, local_path=tmp_path)
519+
assert result == ('COMPLETE', None, None)
520+
assert Path(tmp_path, filename).exists()
521+
508522
@pytest.mark.parametrize("test_data_uri, expected_cloud_uri", [
509523
("mast:HST/product/u24r0102t_c1f.fits",
510524
"s3://stpubdata/hst/public/u24r/u24r0102t/u24r0102t_c1f.fits"),

0 commit comments

Comments
 (0)