try to catch error with xarray
MODIFY
.github/workflows/main.yaml
.github/workflows/main.yaml
@@ -53,7 +53,7 @@ jobs:
- name: Run Tests
shell: bash -l {0}
run: |
- py.test tests -k caching_copying -x -v --redirect-dask-worker-logs-to-stdout=DEBUG \
+ py.test tests/test_storage.py -x -v --redirect-dask-worker-logs-to-stdout=DEBUG \
--cov=pangeo_forge_recipes --cov-config .coveragerc --cov-report term-missing
coverage xml
- name: Codecov

MODIFY
tests/test_storage.py
tests/test_storage.py
import pytest
+import xarray as xr
from dask import delayed
from dask.distributed import Client
from pytest_lazyfixture import lazy_fixture
@@ -44,8 +45,9 @@ def test_metadata_target(tmp_metadata_target):
@pytest.mark.parametrize("copy_to_local", [False, True])
@pytest.mark.parametrize("use_cache, cache_first", [(False, False), (True, False), (True, True)])
@pytest.mark.parametrize("use_dask", [True, False])
+@pytest.mark.parametrize("use_xarray", [True, False])
def test_file_opener(
- file_paths, tmp_cache, copy_to_local, use_cache, cache_first, dask_cluster, use_dask
+ file_paths, tmp_cache, copy_to_local, use_cache, cache_first, dask_cluster, use_dask, use_xarray
):
all_paths, _ = file_paths
path = str(all_paths[0])
@@ -70,7 +72,15 @@ def test_file_opener(
if copy_to_local:
assert isinstance(fp, str)
with open(fp, mode="rb") as fp2:
+ if use_xarray:
+ ds = xr.open_dataset(fp2)
+ ds.load()
+ else:
_ = fp2.read()
+ else:
+ if use_xarray:
+ ds = xr.open_dataset(fp)
+ ds.load()
else:
_ = fp.read()

try to catch error with xarray