MCPcopy
hub / github.com/dask/dask / BlockwiseDepDict

Class BlockwiseDepDict

dask/blockwise.py:81–174  ·  view source on GitHub ↗

Dictionary-based Blockwise-IO argument This is a dictionary-backed instance of ``BlockwiseDep``. The purpose of this class is to simplify the construction of IO-based Blockwise Layers with block/partition-dependent function arguments that are difficult to calculate at graph-mate

Source from the content-addressed store, hash-verified

79
80
81class BlockwiseDepDict(BlockwiseDep):
82 """Dictionary-based Blockwise-IO argument
83
84 This is a dictionary-backed instance of ``BlockwiseDep``.
85 The purpose of this class is to simplify the construction
86 of IO-based Blockwise Layers with block/partition-dependent
87 function arguments that are difficult to calculate at
88 graph-materialization time.
89
90 Examples
91 --------
92
93 Specify an IO-based function for the Blockwise Layer. Note
94 that the function will be passed a single input object when
95 the task is executed (e.g. a single ``tuple`` or ``dict``):
96
97 >>> import pandas as pd
98 >>> func = lambda x: pd.read_csv(**x)
99
100 Use ``BlockwiseDepDict`` to define the input argument to
101 ``func`` for each block/partition:
102
103 >>> dep = BlockwiseDepDict(
104 ... mapping={
105 ... (0,) : {
106 ... "filepath_or_buffer": "data.csv",
107 ... "skiprows": 1,
108 ... "nrows": 2,
109 ... "names": ["a", "b"],
110 ... },
111 ... (1,) : {
112 ... "filepath_or_buffer": "data.csv",
113 ... "skiprows": 3,
114 ... "nrows": 2,
115 ... "names": ["a", "b"],
116 ... },
117 ... }
118 ... )
119
120 Construct a Blockwise Layer with ``dep`` specified
121 in the ``indices`` list:
122
123 >>> layer = Blockwise(
124 ... output="collection-name",
125 ... output_indices="i",
126 ... task=Task("collection-name", func, TaskRef("_0")),
127 ... indices=[(dep, "i")],
128 ... numblocks={},
129 ... )
130
131 See Also
132 --------
133 dask.blockwise.Blockwise
134 dask.blockwise.BlockwiseDep
135 """
136
137 def __init__(
138 self,

Callers 2

__init__Method · 0.90
from_dask_arrayFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…