Skip to content

Commit 3e26521

Browse files
authored
Merge pull request #3113 from snbianco/ASB-28975-update-docs
Move cloud functions into Observations, fix for docs and test
2 parents aa35035 + 4e422d8 commit 3e26521

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

CHANGES.rst

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ mast
218218
- Added function ``mast.Observations.get_unique_product_list`` to return the unique data products associated with
219219
given observations. [#3096]
220220

221+
- Deprecated ``enable_cloud_dataset`` and ``disable_cloud_dataset`` in classes where they
222+
are non-operational. They will be removed in a future release. [#3113]
223+
221224
mpc
222225
^^^
223226

astroquery/mast/core.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
This the base class for MAST queries.
77
"""
8+
from astropy.utils import deprecated
89
from ..query import QueryWithLogin
910
from . import utils
1011
from .auth import MastAuth
11-
from .cloud import CloudAccess
1212
from .discovery_portal import PortalAPI
1313
from .services import ServiceAPI
1414

@@ -82,6 +82,8 @@ def logout(self):
8282
self._auth_obj.logout()
8383
self._authenticated = False
8484

85+
@deprecated(since='v0.4.8',
86+
message=('This function is non-operational and will be removed in a future release.'))
8587
def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True):
8688
"""
8789
Enable downloading public files from S3 instead of MAST.
@@ -98,14 +100,15 @@ def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True):
98100
Default True.
99101
Logger to display extra info and warning.
100102
"""
103+
pass
101104

102-
self._cloud_connection = CloudAccess(provider, profile, verbose)
103-
105+
@deprecated(since='v0.4.8',
106+
message=('This function is non-operational and will be removed in a future release.'))
104107
def disable_cloud_dataset(self):
105108
"""
106-
Disables downloading public files from S3 instead of MAST
109+
Disables downloading public files from S3 instead of MAST.
107110
"""
108-
self._cloud_connection = None
111+
pass
109112

110113
def resolve_object(self, objectname):
111114
"""

astroquery/mast/observations.py

+25
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from astropy.table import Table, Row, unique, vstack
2323
from astroquery import log
24+
from astroquery.mast.cloud import CloudAccess
2425

2526
from ..utils import commons, async_to_sync
2627
from ..utils.class_or_instance import class_or_instance
@@ -171,6 +172,30 @@ def _parse_caom_criteria(self, **criteria):
171172

172173
return position, mashup_filters
173174

175+
def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True):
176+
"""
177+
Enable downloading public files from S3 instead of MAST.
178+
Requires the boto3 library to function.
179+
180+
Parameters
181+
----------
182+
provider : str
183+
Which cloud data provider to use. We may in the future support multiple providers,
184+
though at the moment this argument is ignored.
185+
profile : str
186+
Profile to use to identify yourself to the cloud provider (usually in ~/.aws/config).
187+
verbose : bool
188+
Default True.
189+
Logger to display extra info and warning.
190+
"""
191+
self._cloud_connection = CloudAccess(provider, profile, verbose)
192+
193+
def disable_cloud_dataset(self):
194+
"""
195+
Disables downloading public files from S3 instead of MAST.
196+
"""
197+
self._cloud_connection = None
198+
174199
@class_or_instance
175200
def query_region_async(self, coordinates, *, radius=0.2*u.deg, pagesize=None, page=None):
176201
"""

astroquery/mast/tests/test_mast_remote.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,8 @@ def test_observations_get_cloud_uris_no_duplicates(self, msa_product_table):
499499
# enable access to public AWS S3 bucket
500500
Observations.enable_cloud_dataset(provider='AWS')
501501

502-
# Check for cloud URIs. Accept a NoResultsWarning if AWS S3
503-
# doesn't have the file. It doesn't matter as we're only checking
504-
# that the duplicate products have been culled to a single one.
505-
with pytest.warns(NoResultsWarning):
506-
uris = Observations.get_cloud_uris(products)
502+
# Check that only one URI is returned
503+
uris = Observations.get_cloud_uris(products)
507504
assert len(uris) == 1
508505

509506
def test_observations_download_file(self, tmp_path):

0 commit comments

Comments
 (0)