Dask Tutorial
This tutorial was last given at SciPy 2018 in Austin Texas. A video is available online.
Dask provides multi-core execution on larger-than-memory datasets.
We can think of dask at a high and a low level
High level collections: Dask provides high-level Array, Bag, and DataFrame collections that mimic NumPy, lists, and Pandas but can operate in parallel on datasets that don't fit into main memory. Dask's high-level collections are alternatives to NumPy and Pandas for large datasets.
Low Level schedulers: Dask provides dynamic task schedulers that execute task graphs in parallel. These execution engines power the high-level collections mentioned above but can also power custom, user-defined workloads. These schedulers are low-latency (around 1ms) and work hard to run computations in a small memory footprint. Dask's schedulers are an alternative to direct use of
threading
ormultiprocessing
libraries in complex cases or other task scheduling systems likeLuigi
orIPython parallel
.
Different users operate at different levels but it is useful to understand both. This tutorial will interleave between high-level use of dask.array
and dask.dataframe
(even sections) and low-level use of dask graphs and schedulers (odd sections.)
Prepare
You should clone this repository
and then install necessary packages.
a) Create a conda environment (preferred)
In the main repo directory
b) Install into an existing environment
You will need the following core libraries
You may find the following libraries helpful for some exercises
Note that this options will alter your existing environment, potentially changing the versions of packages you already have installed.
c) Use Dockerfile
You can build a docker image out of the provided Dockerfile.
Run a container, replacing the ID with the output of the previous command
The above command will give an URL (Like http://(container_id or 127.0.0.1):8888/?token=<sometoken>
) which can be used to access the notebook from browser. You may need to replace the given hostname with "localhost" or "127.0.0.1".
Prepare artificial data.
This is also done in the first notebook, but will only make data not already created. You may skip this and only make artificial data as required in the specific sections of the tutorial.
From the repo directory (within the running notebook server if using method c) )
Launch notebook
From the repo directory
This was already done for method c) and does not need repeating.
Links
Reference
Ask for help
dask
tag on Stack Overflow, for usage questionsgithub issues for bug reports and feature requests
gitter chat for general, non-bug, discussion
Attend a live tutorial
Outline
Overview - dask's place in the universe.
Delayed - the single-function way to parallelize general python code.
1x. Lazy - some of the principles behind lazy execution, for the interested.
Bag - the first high-level collection: a generalized iterator for use with a functional programming style and to clean messy data.
Array - blocked numpy-like functionality with a collection of numpy arrays spread across your cluster.
Dataframe - parallelized operations on many pandas dataframes spread across your cluster.
Distributed - Dask's scheduler for clusters, with details of how to view the UI.
Advanced Distributed - further details on distributed computing, including how to debug.
Dataframe Storage - efficient ways to read and write dataframes to disc.
Machine Learning - applying dask to machine-learning problems.