Debian Codegraph @

docs/source/index.rst

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