diff --git a/intake_thredds/source.py b/intake_thredds/source.py index bc7e2cb..2512174 100644 --- a/intake_thredds/source.py +++ b/intake_thredds/source.py @@ -1,14 +1,10 @@ import fnmatch from intake_xarray.base import DataSourceMixin +from tqdm import tqdm from .cat import ThreddsCatalog -try: - from tqdm import tqdm -except ImportError: - tqdm = None - class THREDDSMergedSource(DataSourceMixin): """Merges multiple datasets into a single datasets. @@ -29,9 +25,6 @@ class THREDDSMergedSource(DataSourceMixin): concat_kwargs: dict kwargs to be passed to xr.concat() filled by files opened by xr.open_dataset previously - progressbar : bool - If True, will print a progress bar. Requires `tqdm `__ - to be installed. metadata : dict or None To associate with this source. @@ -67,7 +60,6 @@ def __init__( url, path, driver='opendap', - progressbar=True, xarray_kwargs={}, concat_kwargs=None, metadata=None, @@ -82,13 +74,6 @@ def __init__( self.xarray_kwargs = xarray_kwargs self.concat_kwargs = concat_kwargs self._ds = None - self.progressbar = progressbar - if self.progressbar and tqdm is None: - raise ValueError( - "Missing package 'tqdm' required for progress bars." - 'You can install tqdm via (1) python -m pip install tqdm or (2) conda install -c conda-forge tqdm.' - "In case you don't want to install tqdm, please use `progressbar=False`." - ) def _open_dataset(self): import xarray as xr @@ -102,13 +87,10 @@ def _open_dataset(self): else: break path = self.path[i:] - if self.progressbar: - data = [ - ds(xarray_kwargs=self.xarray_kwargs).to_dask() - for ds in tqdm(_match(cat, path), desc='Dataset(s)', ncols=79) - ] - else: - data = [ds(xarray_kwargs=self.xarray_kwargs).to_dask() for ds in _match(cat, path)] + data = [ + ds(xarray_kwargs=self.xarray_kwargs).to_dask() + for ds in tqdm(_match(cat, path), desc='Dataset(s)', ncols=79) + ] if self.concat_kwargs: self._ds = xr.concat(data, **self.concat_kwargs) else: diff --git a/requirements.txt b/requirements.txt index ebc71d7..f0fef06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ -aiohttp>=3.7 -intake-xarray>=0.3 -intake>=0.6.0 +aiohttp >=3.7 fsspec >=0.8.5 +h5netcdf >=0.8.1 +intake-xarray >=0.3 +intake >=0.6.0 pydap siphon -h5netcdf>=0.8.1 +tqdm diff --git a/setup.cfg b/setup.cfg index 91ffe13..0984905 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,7 +8,7 @@ select = B,C,E,F,W,T4,B9 [isort] known_first_party=intake_thredds -known_third_party=intake,intake_xarray,pkg_resources,pytest,setuptools,xarray +known_third_party=intake,intake_xarray,pkg_resources,pytest,setuptools,tqdm,xarray multi_line_output=3 include_trailing_comma=True force_grid_wrap=0