From 55a3abc5d705671cb75f5834eabcb9099488397c Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 15 May 2018 12:17:12 -0700 Subject: [PATCH] add distributed integration test --- xarray/tests/test_distributed.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xarray/tests/test_distributed.py b/xarray/tests/test_distributed.py index 0ac03327494..8679e892be4 100644 --- a/xarray/tests/test_distributed.py +++ b/xarray/tests/test_distributed.py @@ -17,13 +17,14 @@ from distributed.client import futures_of import xarray as xr -from xarray.tests.test_backends import ON_WINDOWS, create_tmp_file +from xarray.tests.test_backends import (ON_WINDOWS, create_tmp_file, + create_tmp_geotiff) from xarray.tests.test_dataset import create_test_data from xarray.backends.common import HDF5_LOCK, CombinedLock from . import ( - assert_allclose, has_h5netcdf, has_netCDF4, has_scipy, requires_zarr, - raises_regex) + assert_allclose, has_h5netcdf, has_netCDF4, requires_rasterio, has_scipy, + requires_zarr, raises_regex) # this is to stop isort throwing errors. May have been easier to just use # `isort:skip` in retrospect @@ -136,6 +137,17 @@ def test_dask_distributed_zarr_integration_test(loop): assert_allclose(original, computed) +@requires_rasterio +def test_dask_distributed_rasterio_integration_test(loop): + with create_tmp_geotiff() as (tmp_file, expected): + with cluster() as (s, [a, b]): + with Client(s['address'], loop=loop) as c: + da_tiff = xr.open_rasterio(tmp_file, chunks={'band': 1}) + assert isinstance(da_tiff.data, da.Array) + actual = da_tiff.compute() + assert_allclose(actual, expected) + + @pytest.mark.skipif(distributed.__version__ <= '1.19.3', reason='Need recent distributed version to clean up get') @gen_cluster(client=True, timeout=None)