MCPcopy
hub / github.com/dask/dask / collections_to_expr

Function collections_to_expr

dask/base.py:413–452  ·  view source on GitHub ↗

Convert many collections into a single dask expression. Typically, users should not be required to interact with this function. Parameters ---------- collections : Iterable An iterable of dask collections to be combined. optimize_graph : bool, optional If t

(
    collections: Iterable,
    optimize_graph: bool = True,
)

Source from the content-addressed store, hash-verified

411
412
413def collections_to_expr(
414 collections: Iterable,
415 optimize_graph: bool = True,
416) -> Expr:
417 """
418 Convert many collections into a single dask expression.
419
420 Typically, users should not be required to interact with this function.
421
422 Parameters
423 ----------
424 collections : Iterable
425 An iterable of dask collections to be combined.
426 optimize_graph : bool, optional
427 If this is True and collections are encountered which are backed by
428 legacy HighLevelGraph objects, the returned Expression will run a low
429 level task optimization during materialization.
430 """
431 is_iterable = False
432 if isinstance(collections, (tuple, list, set)):
433 is_iterable = True
434 else:
435 collections = [collections]
436 if not collections:
437 raise ValueError("No collections provided")
438 from dask._expr import HLGExpr, _ExprSequence
439
440 graphs = []
441 for coll in collections:
442 from dask.delayed import Delayed
443
444 if isinstance(coll, Delayed) or not hasattr(coll, "expr"):
445 graphs.append(HLGExpr.from_collection(coll, optimize_graph=optimize_graph))
446 else:
447 graphs.append(coll.expr)
448
449 if len(graphs) > 1 or is_iterable:
450 return _ExprSequence(*graphs)
451 else:
452 return graphs[0]
453
454
455def unpack_collections(*args, traverse=True):

Callers 15

finalizeFunction · 0.90
unpack_collectionsFunction · 0.90
to_task_daskFunction · 0.90
_layerMethod · 0.90
test_from_xarrayFunction · 0.90
visualizeFunction · 0.90
test_array_vs_dataframeFunction · 0.90
test_anom_meanFunction · 0.90
test_delayed_fusionFunction · 0.90

Calls 2

_ExprSequenceClass · 0.90
from_collectionMethod · 0.80

Tested by 14

test_from_xarrayFunction · 0.72
visualizeFunction · 0.72
test_array_vs_dataframeFunction · 0.72
test_anom_meanFunction · 0.72
test_delayed_fusionFunction · 0.72
test_trim_internalFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…