Skip to content

Commit f836822

Browse files
authored
Merge pull request #127 from lukecampbell/pass-engine
Pass engine to xr.open_mfdataset in OpenDapSource
2 parents 5c74157 + 4cf22c5 commit f836822

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

ci/environment-py310.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- zarr
2222
- moto < 3
2323
- s3fs
24+
- werkzeug < 2.2.0

ci/environment-py38.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- zarr
2222
- moto < 3
2323
- s3fs
24+
- werkzeug < 2.2.0

ci/environment-py39.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- zarr
2222
- moto < 3
2323
- s3fs
24+
- werkzeug < 2.2.0

ci/environment-upstream.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
- intake
2424
- rioxarray
2525
- gdal
26+
- werkzeug < 2.2.0
2627
- pip:
2728
- git+https://github.com/fsspec/filesystem_spec.git
2829
- git+https://github.com/intake/intake.git

intake_xarray/opendap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _open_dataset(self):
9292
import xarray as xr
9393

9494
if isinstance(self.urlpath, list):
95-
self._ds = xr.open_mfdataset(self.urlpath, chunks=self.chunks, **self._kwargs)
95+
self._ds = xr.open_mfdataset(self.urlpath, chunks=self.chunks, engine=self.engine, **self._kwargs)
9696
else:
9797
store = self._get_store()
98-
self._ds = xr.open_dataset(store, chunks=self.chunks, **self._kwargs)
98+
self._ds = xr.open_dataset(store, chunks=self.chunks, **self._kwargs)

intake_xarray/tests/test_intake_xarray.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,22 @@ def test_read_opendap_with_auth(auth):
332332
)
333333

334334

335+
def test_read_opendap_mfdataset_with_engine():
336+
pytest.importorskip("pydap")
337+
from intake_xarray.opendap import OpenDapSource
338+
urls = [
339+
'http://example.com/opendap/fake1.nc',
340+
'http://example.com/opendap/fake2.nc',
341+
]
342+
with patch('xarray.open_mfdataset') as open_mfdataset_mock:
343+
open_mfdataset_mock.return_value = 'dataset'
344+
source = OpenDapSource(urlpath=urls, chunks={}, auth=None, engine='fake-engine')
345+
source._open_dataset()
346+
retval = source._ds
347+
assert open_mfdataset_mock.called_with(urls, chunks={}, engine='fake-engine')
348+
assert retval == 'dataset'
349+
350+
335351
@pytest.mark.parametrize("auth", ["esgf", "urs"])
336352
def test_read_opendap_with_auth_netcdf4(auth):
337353
from intake_xarray.opendap import OpenDapSource

intake_xarray/tests/test_remote.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,24 @@ def s3_base():
159159
import shlex
160160
import subprocess
161161

162-
proc = subprocess.Popen(shlex.split("moto_server s3 -p %s" % PORT_S3))
162+
proc = subprocess.Popen(shlex.split("moto_server s3 -p %s" % PORT_S3),
163+
stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
163164

164165
timeout = 5
165166
while timeout > 0:
166167
try:
168+
print("polling for moto server")
169+
167170
r = requests.get(endpoint_uri)
168171
if r.ok:
169172
break
170173
except:
171174
pass
172175
timeout -= 0.1
173176
time.sleep(0.1)
177+
print("server up")
174178
yield
179+
print("moto done")
175180
proc.terminate()
176181
proc.wait()
177182

0 commit comments

Comments
 (0)