Debian Codegraph @

docs/source/index.rst

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 ====
2 Dask
3 ====
4
5 .. grid:: 1 1 2 2
6
7 .. grid-item::
8 :columns: 12 12 6 6
9
10 *Dask is a Python library for parallel and distributed computing.* Dask is:
11
12 - **Easy** to use and set up (it's just a Python library)
13 - **Powerful** at providing scale, and unlocking complex algorithms
14 - and **Fun** 🎉
15
16 .. grid-item::
17 :columns: 12 12 6 6
18
19 .. raw:: html
20
21 <script src="https://fast.wistia.com/embed/medias/l9sgt2saht.jsonp" async></script><script src="https://fast.wistia.com/assets/external/E-v1.js" async></script><div class="wistia_responsive_padding" style="padding:75.0% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_l9sgt2saht seo=true videoFoam=true" style="height:100%;position:relative;width:100%">&nbsp;</div></div></div>
22
23
24 How to Use Dask
25 ---------------
26
27 Dask provides several APIs. Choose one that works best for you:
28
29 .. tab-set::
30
31 .. tab-item:: Tasks
32
33 Dask Futures parallelize arbitrary for-loop style Python code,
34 providing:
35
36 - **Flexible** tooling allowing you to construct custom
37 pipelines and workflows
38 - **Powerful** scaling techniques, processing several thousand
39 tasks per second
40 - **Responsive** feedback allowing for intuitive execution,
41 and helpful dashboards
42
43 Dask futures form the foundation for other Dask work
44
45 Learn more at :bdg-link-primary:`Futures Documentation <futures.html>`
46 or see an example at :bdg-link-primary:`Futures Example <https://examples.dask.org/futures.html>`
47
48 .. grid:: 1 1 2 2
49
50 .. grid-item::
51 :columns: 12 12 7 7
52
53 .. code-block:: python
54
55 from dask.distributed import LocalCluster
56 client = LocalCluster().get_client()
57
58 # Submit work to happen in parallel
59 results = []
60 for filename in filenames:
61 data = client.submit(load, filename)
62 result = client.submit(process, data)
63 results.append(result)
64
65 # Gather results back to local computer
66 results = client.gather(results)
67
68 .. grid-item::
69 :columns: 12 12 5 5
70
71 .. figure:: images/futures-graph.png
72 :align: center
73
74 .. tab-item:: DataFrames
75
76 Dask Dataframes parallelize the popular pandas library, providing:
77
78 - **Larger-than-memory** execution for single machines, allowing you
79 to process data that is larger than your available RAM
80 - **Parallel** execution for faster processing
81 - **Distributed** computation for terabyte-sized datasets
82
83 Dask Dataframes are similar in this regard to Apache Spark, but use the
84 familiar pandas API and memory model. One Dask dataframe is simply a
85 collection of pandas dataframes on different computers.
86
87 Learn more at :bdg-link-primary:`DataFrame Documentation <dataframe.html>`
88 or see an example at :bdg-link-primary:`DataFrame Example <https://examples.dask.org/dataframe.html>`
89
90 .. grid:: 1 1 2 2
91
92 .. grid-item::
93 :columns: 12 12 7 7
94
95 .. code-block:: python
96
97 import dask.dataframe as dd
98
99 # Read large datasets in parallel
100 df = dd.read_parquet("s3://mybucket/data.*.parquet")
101 df = df[df.value < 0]
102 result = df.groupby(df.name).amount.mean()
103
104 result = result.compute() # Compute to get pandas result
105 result.plot()
106
107 .. grid-item::
108 :columns: 12 12 5 5
109
110 .. figure:: images/dask-dataframe.svg
111 :align: center
112
113
114 .. tab-item:: Arrays
115
116 Dask Arrays parallelize the popular NumPy library, providing:
117
118 - **Larger-than-memory** execution for single machines, allowing you
119 to process data that is larger than your available RAM
120 - **Parallel** execution for faster processing
121 - **Distributed** computation for terabyte-sized datasets
122
123 Dask Arrays allow scientists and researchers to perform intuitive and
124 sophisticated operations on large datasets but use the
125 familiar NumPy API and memory model. One Dask array is simply a
126 collection of NumPy arrays on different computers.
127
128 Learn more at :bdg-link-primary:`Array Documentation <array.html>`
129 or see an example at :bdg-link-primary:`Array Example <https://examples.dask.org/array.html>`
130
131 .. grid:: 1 1 2 2
132
133 .. grid-item::
134
135 .. code-block:: python
136
137 import dask.array as da
138
139 x = da.random.random((10000, 10000))
140 y = (x + x.T) - x.mean(axis=1)
141
142 z = y.var(axis=0).compute()
143
144 .. grid-item::
145 :columns: 12 12 5 5
146
147 .. figure:: images/dask-array.svg
148 :align: center
149
150 Xarray wraps Dask array and is a popular downstream project, providing
151 labeled axes and simultaneously tracking many Dask arrays together,
152 resulting in more intuitive analyses. Xarray is popular and accounts
153 for the majority of Dask array use today especially within geospatial
154 and imaging communities.
155
156 Learn more at :bdg-link-primary:`Xarray Documentation <https://docs.xarray.dev/en/stable/>`
157 or see an example at :bdg-link-primary:`Xarray Example <https://examples.dask.org/xarray.html>`
158
159 .. grid:: 1 1 2 2
160
161 .. grid-item::
162
163 .. code-block:: python
164
165 import xarray as xr
166
167 ds = xr.open_mfdataset("data/*.nc")
168 da.groupby('time.month').mean('time').compute()
169
170
171 .. grid-item::
172 :columns: 12 12 5 5
173
174 .. figure:: images/Xarray_Logo_RGB_Final.png
175 :align: center
176
177 .. tab-item:: Bags
178
179 Dask Bags are simple parallel Python lists, commonly used to process
180 text or raw Python objects. They are ...
181
182 - **Simple** offering easy map and reduce functionality
183 - **Low-memory** processing data in a streaming way that minimizes memory use
184 - **Good for preprocessing** especially for text or JSON data prior
185 ingestion into dataframes
186
187 Dask bags are similar in this regard to Spark RDDs or vanilla
188 Python data structures and iterators. One Dask bag is simply a
189 collection of Python iterators processing in parallel on different computers.
190
191 Learn more at :bdg-link-primary:`Bag Documentation <bag.html>`
192 or see an example at :bdg-link-primary:`Bag Example <https://examples.dask.org/bag.html>`
193
194 .. code-block:: python
195
196 import dask.bag as db
197
198 # Read large datasets in parallel
199 lines = db.read_text("s3://mybucket/data.*.json")
200 records = (lines
201 .map(json.loads)
202 .filter(lambda d: d["value"] > 0)
203 )
204 df = records.to_dask_dataframe()
205
206 How to Install Dask
207 -------------------
208
209 Installing Dask is easy with ``pip`` or ``conda``.
210
211 Learn more at :bdg-link-primary:`Install Documentation <install.html>`
212
213 .. tab-set::
214
215 .. tab-item:: pip
216
217 .. code-block::
218
219 pip install "dask[complete]"
220
221 .. tab-item:: conda
222
223 .. code-block::
224
225 conda install dask
226
227 How to Deploy Dask
228 ------------------
229
230 You can use Dask on a single machine, or deploy it on distributed hardware.
231
232 Learn more at :bdg-link-primary:`Deploy Documentation <deploying.html>`
233
234 .. tab-set::
235
236 .. tab-item:: Local
237
238 Dask can set itself up easily in your Python session if you create a
239 ``LocalCluster`` object, which sets everything up for you.
240
241 .. code-block:: python
242
243 from dask.distributed import LocalCluster
244 cluster = LocalCluster()
245 client = cluster.get_client()
246
247 # Normal Dask work ...
248
249 Alternatively, you can skip this part, and Dask will operate within a
250 thread pool contained entirely with your local process.
251
252 .. tab-item:: Cloud
253
254 `Coiled <https://docs.coiled.io/user_guide/index.html?utm_source=dask-docs&utm_medium=homepage>`_
255 is a commercial SaaS product that deploys Dask clusters on cloud platforms like AWS, GCP, and Azure.
256
257 .. code-block:: python
258
259 import coiled
260 cluster = coiled.Cluster(
261 n_workers=100,
262 region="us-east-2",
263 worker_memory="16 GiB",
264 spot_policy="spot_with_fallback",
265 )
266 client = cluster.get_client()
267
268 Learn more at :bdg-link-primary:`Coiled Documentation <https://docs.coiled.io/user_guide/index.html?utm_source=dask-docs&utm_medium=homepage>`
269
270
271 .. tab-item:: HPC
272
273 The `Dask-Jobqueue project <https://jobqueue.dask.org>`_ deploys
274 Dask clusters on popular HPC job submission systems like SLURM, PBS, SGE, LSF,
275 Torque, Condor, and others.
276
277 .. code-block:: python
278
279 from dask_jobqueue import PBSCluster
280 cluster = PBSCluster(
281 cores=24,
282 memory="100GB",
283 queue="regular",
284 account="my-account",
285 )
286 cluster.scale(jobs=100)
287 client = cluster.get_client()
288
289 Learn more at :bdg-link-primary:`Dask-Jobqueue Documentation <https://jobqueue.dask.org>`
290
291 .. tab-item:: Kubernetes
292
293 The `Dask Kubernetes project <https://kubernetes.dask.org>`_ provides
294 a Dask Kubernetes Operator for deploying Dask on Kubernetes clusters.
295
296 .. code-block:: python
297
298 from dask_kubernetes.operator import KubeCluster
299 cluster = KubeCluster(
300 name="my-dask-cluster",
301 image="ghcr.io/dask/dask:latest",
302 resources={"requests": {"memory": "2Gi"}, "limits": {"memory": "64Gi"}},
303 )
304 cluster.scale(10)
305 client = cluster.get_client()
306
307
308 Learn more at :bdg-link-primary:`Dask Kubernetes Documentation <https://kubernetes.dask.org>`
309
310
311 Learn with Examples
312 -------------------
313
314 Dask use is widespread, across all industries and scales. Dask is used
315 anywhere Python is used and people experience pain due to large scale data, or
316 intense computing.
317
318 You can learn more about Dask applications at the following sources:
319
320 - `Dask Examples <https://examples.dask.org>`_
321 - `Dask YouTube Channel <https://youtube.com/@dask-dev>`_
322
323 Additionally, we encourage you to look through the reference documentation on
324 this website related to the API that most closely matches your application.
325
326 Dask was designed to be **easy to use** and **powerful**. We hope that it's
327 able to help you have fun with your work.
328
329 .. toctree::
330 :maxdepth: 1
331 :hidden:
332 :caption: Getting Started
333
334 Install Dask <install.rst>
335 10-minutes-to-dask.rst
336 deploying.rst
337 Best Practices <best-practices.rst>
338 faq.rst
339
340 .. toctree::
341 :maxdepth: 1
342 :hidden:
343 :caption: How to Use
344
345 array.rst
346 bag.rst
347 DataFrame <dataframe.rst>
348 Delayed <delayed.rst>
349 futures.rst
350 ml.rst
351
352 .. toctree::
353 :maxdepth: 1
354 :hidden:
355 :caption: Internals
356
357 understanding-performance.rst
358 scheduling.rst
359 graphs.rst
360 debugging-performance.rst
361 internals.rst
362
363 .. toctree::
364 :maxdepth: 1
365 :hidden:
366 :caption: Reference
367
368 api.rst
369 cli.rst
370 develop.rst
371 changelog.rst
372 configuration.rst
373 how-to/index.rst
374 presentations.rst
375 maintainers.rst
376
377 .. _`Anaconda Inc`: https://www.anaconda.com
378 .. _`3-clause BSD license`: https://github.com/dask/dask/blob/main/LICENSE.txt
379
380 .. _`#dask tag`: https://stackoverflow.com/questions/tagged/dask
381 .. _`GitHub issue tracker`: https://github.com/dask/dask/issues
382 .. _`xarray`: https://xarray.pydata.org/en/stable/
383 .. _`scikit-image`: https://scikit-image.org/docs/stable/
384 .. _`scikit-allel`: https://scikits.appspot.com/scikit-allel
385 .. _`pandas`: https://pandas.pydata.org/pandas-docs/version/0.17.0/
386 .. _`distributed scheduler`: https://distributed.dask.org/en/latest/