MCPcopy Index your code
hub / github.com/pydata/xarray / _dataset_from_backend_dataset

Function _dataset_from_backend_dataset

xarray/backends/api.py:282–329  ·  view source on GitHub ↗
(
    backend_ds,
    filename_or_obj,
    engine,
    chunks,
    cache,
    overwrite_encoded_chunks,
    inline_array,
    chunked_array_type,
    from_array_kwargs,
    create_default_indexes,
    **extra_tokens,
)

Source from the content-addressed store, hash-verified

280
281
282def _dataset_from_backend_dataset(
283 backend_ds,
284 filename_or_obj,
285 engine,
286 chunks,
287 cache,
288 overwrite_encoded_chunks,
289 inline_array,
290 chunked_array_type,
291 from_array_kwargs,
292 create_default_indexes,
293 **extra_tokens,
294):
295 if not isinstance(chunks, int | dict) and chunks not in {None, "auto"}:
296 raise ValueError(
297 f"chunks must be an int, dict, 'auto', or None. Instead found {chunks}."
298 )
299
300 _protect_dataset_variables_inplace(backend_ds, cache)
301
302 if create_default_indexes:
303 ds = _maybe_create_default_indexes(backend_ds)
304 else:
305 ds = backend_ds
306
307 if chunks is not None:
308 ds = _chunk_ds(
309 ds,
310 filename_or_obj,
311 engine,
312 chunks,
313 overwrite_encoded_chunks,
314 inline_array,
315 chunked_array_type,
316 from_array_kwargs,
317 **extra_tokens,
318 )
319
320 ds.set_close(backend_ds._close)
321
322 # Ensure source filename always stored in dataset object
323 if "source" not in ds.encoding:
324 path = getattr(filename_or_obj, "path", filename_or_obj)
325
326 if isinstance(path, str | os.PathLike):
327 ds.encoding["source"] = _normalize_path(path)
328
329 return ds
330
331
332def _datatree_from_backend_datatree(

Callers 2

open_datasetFunction · 0.85
open_groupsFunction · 0.85

Calls 5

_normalize_pathFunction · 0.90
_chunk_dsFunction · 0.85
set_closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…