13
13
14
14
from astropy .logger import log
15
15
from astropy .utils .console import ProgressBarOrSpinner
16
+ from astropy .utils .exceptions import AstropyDeprecationWarning
16
17
17
18
from ..exceptions import NoResultsWarning , InvalidQueryError
18
19
@@ -44,25 +45,24 @@ def __init__(self, provider="AWS", profile=None, verbose=False):
44
45
Default False. Display extra info and warnings if true.
45
46
"""
46
47
48
+ # Dealing with deprecated argument
49
+ if profile is not None :
50
+ warnings .warn (("MAST Open Data on AWS is now free to access and does "
51
+ "not require an AWS account" ), AstropyDeprecationWarning )
52
+
47
53
import boto3
48
54
import botocore
49
55
50
56
self .supported_missions = ["mast:hst/product" , "mast:tess/product" , "mast:kepler" ]
51
57
52
- if profile is not None :
53
- self .boto3 = boto3 .Session (profile_name = profile )
54
- else :
55
- self .boto3 = boto3
58
+ self .boto3 = boto3
56
59
self .botocore = botocore
60
+ self .config = botocore .client .Config (signature_version = botocore .UNSIGNED )
57
61
58
62
self .pubdata_bucket = "stpubdata"
59
63
60
64
if verbose :
61
65
log .info ("Using the S3 STScI public dataset" )
62
- log .warning ("Your AWS account will be charged for access to the S3 bucket" )
63
- log .info ("See Request Pricing in https://aws.amazon.com/s3/pricing/ for details" )
64
- log .info ("If you have not configured boto3, follow the instructions here: "
65
- "https://boto3.readthedocs.io/en/latest/guide/configuration.html" )
66
66
67
67
def is_supported (self , data_product ):
68
68
"""
@@ -110,7 +110,7 @@ def get_cloud_uri(self, data_product, include_bucket=True, full_url=False):
110
110
found in the cloud, None is returned.
111
111
"""
112
112
113
- s3_client = self .boto3 .client ('s3' )
113
+ s3_client = self .boto3 .client ('s3' , config = self . config )
114
114
115
115
path = utils .mast_relative_path (data_product ["dataURI" ])
116
116
if path is None :
@@ -119,7 +119,7 @@ def get_cloud_uri(self, data_product, include_bucket=True, full_url=False):
119
119
path = path .lstrip ("/" )
120
120
121
121
try :
122
- s3_client .head_object (Bucket = self .pubdata_bucket , Key = path , RequestPayer = 'requester' )
122
+ s3_client .head_object (Bucket = self .pubdata_bucket , Key = path )
123
123
if include_bucket :
124
124
path = "s3://{}/{}" .format (self .pubdata_bucket , path )
125
125
elif full_url :
@@ -172,8 +172,8 @@ def download_file(self, data_product, local_path, cache=True):
172
172
Default is True. If file is found on disc it will not be downloaded again.
173
173
"""
174
174
175
- s3 = self .boto3 .resource ('s3' )
176
- s3_client = self .boto3 .client ('s3' )
175
+ s3 = self .boto3 .resource ('s3' , config = self . config )
176
+ s3_client = self .boto3 .client ('s3' , config = self . config )
177
177
bkt = s3 .Bucket (self .pubdata_bucket )
178
178
with warnings .catch_warnings ():
179
179
warnings .simplefilter ("ignore" )
@@ -182,7 +182,7 @@ def download_file(self, data_product, local_path, cache=True):
182
182
raise Exception ("Unable to locate file {}." .format (data_product ['productFilename' ]))
183
183
184
184
# Ask the webserver (in this case S3) what the expected content length is and use that.
185
- info_lookup = s3_client .head_object (Bucket = self .pubdata_bucket , Key = bucket_path , RequestPayer = 'requester' )
185
+ info_lookup = s3_client .head_object (Bucket = self .pubdata_bucket , Key = bucket_path )
186
186
length = info_lookup ["ContentLength" ]
187
187
188
188
if cache and os .path .exists (local_path ):
@@ -219,5 +219,4 @@ def progress_callback(numbytes):
219
219
bytes_read += numbytes
220
220
pb .update (bytes_read )
221
221
222
- bkt .download_file (bucket_path , local_path , ExtraArgs = {"RequestPayer" : "requester" },
223
- Callback = progress_callback )
222
+ bkt .download_file (bucket_path , local_path , Callback = progress_callback )
0 commit comments