def test_open_asset_preprocess_error(): path = os.path.join( here, './sample_data/cesm-le/b.e11.B1850C5CN.f09_g16.005.pop.h.SHF.040001-049912.nc' ) print(path) path = f'file://{path}' mapper = fsspec.get_mapper(path) def preprocess(ds): return ds.set_coords('foo') with pytest.raises(RuntimeError): _open_asset(mapper, 'netcdf', cdf_kwargs={}, varname=['SHF'], preprocess=preprocess)
def test_open_asset(path, data_format, storage_options): x = _path_to_mapper(path, storage_options, data_format) ds = _open_asset(x, data_format, cdf_kwargs={'chunks': {}}, zarr_kwargs={'consolidated': True}) assert isinstance(ds, xr.Dataset)
def test_open_asset_error(path, data_format, error): with pytest.raises(error): _open_asset(path, data_format, {}, {}, None, 'Tair')