Skip to content

Commit

Permalink
Remove download sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Aug 17, 2023
1 parent d1cfa6b commit 4df5b2e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
3 changes: 1 addition & 2 deletions sunpy/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sunpy
from sunpy import config
from sunpy.data._sample import download_sample_data
from sunpy.data.data_manager.cache import Cache
from sunpy.data.data_manager.downloader import ParfiveDownloader
from sunpy.data.data_manager.manager import DataManager
Expand All @@ -26,4 +25,4 @@
expiry=int(config.get('downloads', 'cache_expiry')) * u.day
)

__all__ = ["download_sample_data", "manager", "cache"]
__all__ = ["manager", "cache"]
41 changes: 0 additions & 41 deletions sunpy/data/_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from sunpy import log
from sunpy.util.config import _is_writable_dir, get_and_create_sample_dir
from sunpy.util.decorators import deprecated
from sunpy.util.parfive_helpers import Downloader

_BASE_URLS = (
Expand Down Expand Up @@ -135,46 +134,6 @@ def _get_sampledata_dir():
return sampledata_dir


@deprecated('4.1', alternative='`sunpy.data.sample.download_all`')
def download_sample_data(overwrite=False):
"""
Download all sample data at once. This will overwrite any existing files.
Parameters
----------
overwrite : `bool`
Overwrite existing sample data.
"""
sampledata_dir = _get_sampledata_dir()

already_downloaded = []
to_download = []
for url_file_name in _SAMPLE_FILES.keys():
fname = sampledata_dir/url_file_name
# We want to avoid calling download if we already have all the files.
if fname.exists() and not overwrite:
already_downloaded.append(fname)
else:
# URL and Filename pairs
to_download.append((url_file_name, fname))

if to_download:
results = _download_sample_data(_BASE_URLS[0], to_download, overwrite=overwrite)
else:
return already_downloaded

# Something went wrong.
if results.errors:
for next_url in _BASE_URLS[1:]:
results = _retry_sample_data(results, next_url)
if not results.errors:
break
else:
_handle_final_errors(results)

return results + already_downloaded


def _get_sample_files(filename_list, no_download=False, force_download=False):
"""
Returns a list of disk locations corresponding to a list of filenames for
Expand Down

0 comments on commit 4df5b2e

Please sign in to comment.