Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions scripts/download_data.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import sys
import time

import bokeh
from packaging.version import Version


def retry(func, *args, **kwargs):
for i in range(5):
try:
return func(*args, **kwargs)
except Exception as e:
wait = 10 * 2**i
print(f'Attempt {i + 1} failed: {e}. Retrying in {wait}s...', file=sys.stderr)
time.sleep(wait)
return func(*args, **kwargs)


if Version(bokeh.__version__).release < (3, 5, 0):
import bokeh.sampledata

bokeh.sampledata.download()
retry(bokeh.sampledata.download)
print('bokeh data downloaded.')

try:
import pooch # noqa: F401
import scipy # noqa: F401
import xarray as xr

xr.tutorial.open_dataset('air_temperature')
xr.tutorial.open_dataset('rasm')
retry(xr.tutorial.open_dataset, 'air_temperature')
retry(xr.tutorial.open_dataset, 'rasm', decode_times=False)
print('xarray data downloaded.')
except ModuleNotFoundError as e:
print(f'ModuleNotFoundError when attempting to download xarray datasets : {e}')
Loading