##// END OF EJS Templates
Adding back deleted file.
Adding back deleted file.

File last commit:

r4910:0dc49390
r6033:0359fcaa
Show More
task1.ipynb
88 lines | 3.0 KiB | text/plain | TextLexer
Brian E. Granger
Converting notebooks to JSON format.
r4634 {
"nbformat": 2,
Brian E. Granger
Implemented metadata for notebook format.
r4637 "metadata": {
"name": "task_1"
},
Brian E. Granger
Converting notebooks to JSON format.
r4634 "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()"
}
]
}
]
}