Skip to content

Dask

Dask Collections

Frisky supports Dask graph protocols, allowing it to compute traditional Dask collections:

import dask.array as da
from frisky import LocalCluster

with LocalCluster(n_workers=4) as cluster:
    with cluster.get_client() as client:
        x = da.ones((1_000, 1_000), chunks=(250, 250))
        x = client.persist(x)

        total = client.compute(x.sum())
        print(total.result())

Use client.compute and client.persist when you create a Frisky cluster directly. Bare Dask calls like x.compute() work after frisky.hijack, shown below.

Deploy on Dask Clusters

Frisky can deploy on top of an existing Dask cluster. This makes it easy to use Frisky with your existing Dask infrastructure. Use frisky.hijack:

import dask.array as da
import frisky
from dask.distributed import Client as DaskClient, LocalCluster

with LocalCluster(n_workers=2, threads_per_worker=1) as dask_cluster:
    with DaskClient(dask_cluster) as dask_client:
        client = frisky.hijack(dask_client)
        x = da.ones((1_000, 1_000), chunks=(250, 250))
        print(x.sum().compute())

See Deployment for local, manual, Dask, and Coiled deployment options.