Skip to content

Commit 61f1017

Browse files
snbiancobsipocz
authored andcommitted
move functions into obs class, fix test
1 parent aa35035 commit 61f1017

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

astroquery/mast/core.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ..query import QueryWithLogin
99
from . import utils
1010
from .auth import MastAuth
11-
from .cloud import CloudAccess
1211
from .discovery_portal import PortalAPI
1312
from .services import ServiceAPI
1413

@@ -82,31 +81,6 @@ def logout(self):
8281
self._auth_obj.logout()
8382
self._authenticated = False
8483

85-
def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True):
86-
"""
87-
Enable downloading public files from S3 instead of MAST.
88-
Requires the boto3 library to function.
89-
90-
Parameters
91-
----------
92-
provider : str
93-
Which cloud data provider to use. We may in the future support multiple providers,
94-
though at the moment this argument is ignored.
95-
profile : str
96-
Profile to use to identify yourself to the cloud provider (usually in ~/.aws/config).
97-
verbose : bool
98-
Default True.
99-
Logger to display extra info and warning.
100-
"""
101-
102-
self._cloud_connection = CloudAccess(provider, profile, verbose)
103-
104-
def disable_cloud_dataset(self):
105-
"""
106-
Disables downloading public files from S3 instead of MAST
107-
"""
108-
self._cloud_connection = None
109-
11084
def resolve_object(self, objectname):
11185
"""
11286
Resolves an object name to a position on the sky.

astroquery/mast/observations.py

Lines changed: 25 additions & 0 deletions
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

Lines changed: 2 additions & 5 deletions
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)