IPython Integration

Dask.distributed integrates with IPython in three ways:

  • You can launch a Dask.distributed cluster from an IPyParallel cluster
  • You can launch IPython kernels from Dask Workers and Schedulers to assistwith debugging
  • They both support the common concurrent.futures interface

Launch Dask from IPyParallel

IPyParallel is IPython’s distributed computing framework that allows you toeasily manage many IPython engines on different computers.

An IPyParallel Client can launch a dask.distributed Scheduler andWorkers on those IPython engines, effectively launching a full dask.distributedsystem.

This is possible with the Client.become_dask method:

  1. $ ipcluster start
  1. >>> from ipyparallel import Client
  2. >>> c = Client() # connect to IPyParallel cluster
  3.  
  4. >>> e = c.become_dask() # start dask on top of IPyParallel
  5. >>> e
  6. <Client: scheduler="127.0.0.1:59683" processes=8 cores=8>

Launch IPython within Dask Workers

It is sometimes convenient to inspect the Worker or Scheduler processinteractively. Fortunately IPython gives us a way to launch interactivesessions within Python processes. This is available through the followingmethods:

Client.start_ipython_workers(self[, …])Start IPython kernels on workers
Client.start_ipython_scheduler(self[, …])Start IPython kernel on the scheduler

These methods start IPython kernels running in a separate thread within thespecified Worker or Schedulers. These kernels are accessible either throughIPython magics or a QT-Console.

Example with IPython Magics

  1. >>> e.start_ipython_scheduler()
  2. >>> %scheduler scheduler.processing
  3. {'127.0.0.1:3595': ['inc-1', 'inc-2'],
  4. '127.0.0.1:53589': ['inc-2', 'add-5']}
  5.  
  6. >>> info = e.start_ipython_workers()
  7. >>> %remote info['127.0.0.1:3595'] worker.active
  8. {'inc-1', 'inc-2'}

Example with qt-console

You can also open up a full interactive IPython qt-console on the scheduleror each of the workers:

  1. >>> e.start_ipython_scheduler(qtconsole=True)
  2. >>> e.start_ipython_workers(qtconsole=True)