{
    "nbformat": 2, 
    "metadata": {
        "name": "task_1"
    }, 
    "worksheets": [
        {
            "cells": [
                {
                    "source": "# Simple task farming example", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [], 
                    "collapsed": true, 
                    "prompt_number": 3, 
                    "input": "from IPython.parallel import Client"
                }, 
                {
                    "source": "A `Client.load_balanced_view` is used to get the object used for working with load balanced tasks.", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [], 
                    "collapsed": true, 
                    "prompt_number": 4, 
                    "input": "rc = Client()\nv = rc.load_balanced_view()"
                }, 
                {
                    "source": "Set the variable `d` on all engines:", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [], 
                    "collapsed": true, 
                    "prompt_number": 5, 
                    "input": "rc[:]['d'] = 30"
                }, 
                {
                    "source": "Define a function that will be our task:", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [], 
                    "collapsed": true, 
                    "prompt_number": 6, 
                    "input": "def task(a):\n    return a, 10*d, a*10*d"
                }, 
                {
                    "source": "Run the task once:", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [], 
                    "collapsed": true, 
                    "prompt_number": 7, 
                    "input": "ar = v.apply(task, 5)"
                }, 
                {
                    "source": "Print the results:", 
                    "cell_type": "markdown"
                }, 
                {
                    "cell_type": "code", 
                    "language": "python", 
                    "outputs": [
                        {
                            "output_type": "stream", 
                            "text": "a, b, c:  [5, 300, 1500]"
                        }
                    ], 
                    "collapsed": false, 
                    "prompt_number": 8, 
                    "input": "print \"a, b, c: \", ar.get()"
                }
            ]
        }
    ]
}