File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ import time
3+
14import bokeh
25from packaging .version import Version
36
7+
8+ def retry (func , * args , ** kwargs ):
9+ for i in range (5 ):
10+ try :
11+ return func (* args , ** kwargs )
12+ except Exception as e :
13+ wait = 10 * 2 ** i
14+ print (f'Attempt { i + 1 } failed: { e } . Retrying in { wait } s...' , file = sys .stderr )
15+ time .sleep (wait )
16+ return func (* args , ** kwargs )
17+
18+
419if Version (bokeh .__version__ ).release < (3 , 5 , 0 ):
520 import bokeh .sampledata
621
7- bokeh .sampledata .download ( )
22+ retry ( bokeh .sampledata .download )
823 print ('bokeh data downloaded.' )
924
1025try :
1126 import pooch # noqa: F401
1227 import scipy # noqa: F401
1328 import xarray as xr
1429
15- xr .tutorial .open_dataset ( 'air_temperature' )
16- xr .tutorial .open_dataset ( 'rasm' )
30+ retry ( xr .tutorial .open_dataset , 'air_temperature' )
31+ retry ( xr .tutorial .open_dataset , 'rasm' , decode_times = False )
1732 print ('xarray data downloaded.' )
1833except ModuleNotFoundError as e :
1934 print (f'ModuleNotFoundError when attempting to download xarray datasets : { e } ' )
You can’t perform that action at this time.
0 commit comments