MCPcopy Index your code
hub / github.com/dask/dask / compute

Function compute

dask/base.py:601–687  ·  view source on GitHub ↗

Compute several dask collections at once. Parameters ---------- args : object Any number of objects. If it is a dask object, it's computed and the result is returned. By default, python builtin collections are also traversed to look for dask objects (for more inf

(
    *args,
    traverse=True,
    optimize_graph=True,
    scheduler=None,
    get=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

599
600
601def compute(
602 *args,
603 traverse=True,
604 optimize_graph=True,
605 scheduler=None,
606 get=None,
607 **kwargs,
608):
609 """Compute several dask collections at once.
610
611 Parameters
612 ----------
613 args : object
614 Any number of objects. If it is a dask object, it's computed and the
615 result is returned. By default, python builtin collections are also
616 traversed to look for dask objects (for more information see the
617 ``traverse`` keyword). Non-dask arguments are passed through unchanged.
618 traverse : bool, optional
619 By default dask traverses builtin python collections looking for dask
620 objects passed to ``compute``. For large collections this can be
621 expensive. If none of the arguments contain any dask objects, set
622 ``traverse=False`` to avoid doing this traversal.
623 scheduler : string, optional
624 Which scheduler to use like "threads", "synchronous" or "processes".
625 If not provided, the default is to check the global settings first,
626 and then fall back to the collection defaults.
627 optimize_graph : bool, optional
628 If True [default], the optimizations for each collection are applied
629 before computation. Otherwise the graph is run as is. This can be
630 useful for debugging.
631 get : ``None``
632 Should be left to ``None`` The get= keyword has been removed.
633 kwargs
634 Extra keywords to forward to the scheduler function.
635
636 Examples
637 --------
638 >>> import dask
639 >>> import dask.array as da
640 >>> a = da.arange(10, chunks=2).sum()
641 >>> b = da.arange(10, chunks=2).mean()
642 >>> dask.compute(a, b)
643 (np.int64(45), np.float64(4.5))
644
645 By default, dask objects inside python collections will also be computed:
646
647 >>> dask.compute({'a': a, 'b': b, 'c': 1})
648 ({'a': np.int64(45), 'b': np.float64(4.5), 'c': 1},)
649 """
650
651 collections, repack = unpack_collections(*args, traverse=traverse)
652 if not collections:
653 return args
654
655 schedule = get_scheduler(
656 scheduler=scheduler,
657 collections=collections,
658 get=get,

Callers 11

test_compute_arrayFunction · 0.90
test_compute_dataframeFunction · 0.90
test_compute_array_bagFunction · 0.90
test_compute_nestedFunction · 0.90
test_optimize_nestedFunction · 0.90
test_persist_nestedFunction · 0.90
test_num_workers_configFunction · 0.90
computeMethod · 0.70

Calls 10

FinalizeComputeClass · 0.90
shorten_tracebackClass · 0.90
flattenFunction · 0.90
get_schedulerFunction · 0.85
collections_to_exprFunction · 0.85
scheduleFunction · 0.85
repackFunction · 0.85
unpack_collectionsFunction · 0.70
optimizeMethod · 0.45
__dask_keys__Method · 0.45

Tested by 10

test_compute_arrayFunction · 0.72
test_compute_dataframeFunction · 0.72
test_compute_array_bagFunction · 0.72
test_compute_nestedFunction · 0.72
test_optimize_nestedFunction · 0.72
test_persist_nestedFunction · 0.72
test_num_workers_configFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…