diff --git a/CHANGES.rst b/CHANGES.rst index fab4c64d0e..6dcf6803dc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -218,6 +218,9 @@ mast - Added function ``mast.Observations.get_unique_product_list`` to return the unique data products associated with given observations. [#3096] +- Deprecated ``enable_cloud_dataset`` and ``disable_cloud_dataset`` in classes where they + are non-operational. They will be removed in a future release. [#3113] + mpc ^^^ diff --git a/astroquery/mast/core.py b/astroquery/mast/core.py index 712579a383..a937c7f9b2 100644 --- a/astroquery/mast/core.py +++ b/astroquery/mast/core.py @@ -5,10 +5,10 @@ This the base class for MAST queries. """ +from astropy.utils import deprecated from ..query import QueryWithLogin from . import utils from .auth import MastAuth -from .cloud import CloudAccess from .discovery_portal import PortalAPI from .services import ServiceAPI @@ -82,6 +82,8 @@ def logout(self): self._auth_obj.logout() self._authenticated = False + @deprecated(since='v0.4.8', + message=('This function is non-operational and will be removed in a future release.')) def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True): """ Enable downloading public files from S3 instead of MAST. @@ -98,14 +100,15 @@ def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True): Default True. Logger to display extra info and warning. """ + pass - self._cloud_connection = CloudAccess(provider, profile, verbose) - + @deprecated(since='v0.4.8', + message=('This function is non-operational and will be removed in a future release.')) def disable_cloud_dataset(self): """ - Disables downloading public files from S3 instead of MAST + Disables downloading public files from S3 instead of MAST. """ - self._cloud_connection = None + pass def resolve_object(self, objectname): """ diff --git a/astroquery/mast/observations.py b/astroquery/mast/observations.py index a1f4ba8a2e..a0e595c6ba 100644 --- a/astroquery/mast/observations.py +++ b/astroquery/mast/observations.py @@ -21,6 +21,7 @@ from astropy.table import Table, Row, unique, vstack from astroquery import log +from astroquery.mast.cloud import CloudAccess from ..utils import commons, async_to_sync from ..utils.class_or_instance import class_or_instance @@ -171,6 +172,30 @@ def _parse_caom_criteria(self, **criteria): return position, mashup_filters + def enable_cloud_dataset(self, provider="AWS", profile=None, verbose=True): + """ + Enable downloading public files from S3 instead of MAST. + Requires the boto3 library to function. + + Parameters + ---------- + provider : str + Which cloud data provider to use. We may in the future support multiple providers, + though at the moment this argument is ignored. + profile : str + Profile to use to identify yourself to the cloud provider (usually in ~/.aws/config). + verbose : bool + Default True. + Logger to display extra info and warning. + """ + self._cloud_connection = CloudAccess(provider, profile, verbose) + + def disable_cloud_dataset(self): + """ + Disables downloading public files from S3 instead of MAST. + """ + self._cloud_connection = None + @class_or_instance def query_region_async(self, coordinates, *, radius=0.2*u.deg, pagesize=None, page=None): """ diff --git a/astroquery/mast/tests/test_mast_remote.py b/astroquery/mast/tests/test_mast_remote.py index 0316179e70..911d778628 100644 --- a/astroquery/mast/tests/test_mast_remote.py +++ b/astroquery/mast/tests/test_mast_remote.py @@ -499,11 +499,8 @@ def test_observations_get_cloud_uris_no_duplicates(self, msa_product_table): # enable access to public AWS S3 bucket Observations.enable_cloud_dataset(provider='AWS') - # Check for cloud URIs. Accept a NoResultsWarning if AWS S3 - # doesn't have the file. It doesn't matter as we're only checking - # that the duplicate products have been culled to a single one. - with pytest.warns(NoResultsWarning): - uris = Observations.get_cloud_uris(products) + # Check that only one URI is returned + uris = Observations.get_cloud_uris(products) assert len(uris) == 1 def test_observations_download_file(self, tmp_path):