helloworld.ipynb
91 lines
| 1.8 KiB
| text/plain
|
TextLexer
Brian E. Granger
|
r4634 | { | |
MinRK
|
r5981 | "metadata": { | |
"name": "helloworld" | |||
Brian Granger
|
r6035 | }, | |
"nbformat": 3, | |||
MinRK
|
r5981 | "worksheets": [ | |
{ | |||
"cells": [ | |||
{ | |||
Brian Granger
|
r6035 | "cell_type": "markdown", | |
MinRK
|
r5981 | "source": [ | |
Brian Granger
|
r6035 | "# Distributed hello world", | |
"", | |||
MinRK
|
r5981 | "Originally by Ken Kinder (ken at kenkinder dom com)" | |
] | |||
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
MinRK
|
r5981 | "input": [ | |
"from IPython.parallel import Client" | |||
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
MinRK
|
r5981 | "prompt_number": 1 | |
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
MinRK
|
r5981 | "input": [ | |
Brian Granger
|
r6035 | "rc = Client()", | |
MinRK
|
r5981 | "view = rc.load_balanced_view()" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
MinRK
|
r5981 | "prompt_number": 2 | |
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
MinRK
|
r5981 | "input": [ | |
Brian Granger
|
r6035 | "def sleep_and_echo(t, msg):", | |
" import time", | |||
" time.sleep(t)", | |||
MinRK
|
r5981 | " return msg" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
MinRK
|
r5981 | "prompt_number": 3 | |
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
MinRK
|
r5981 | "input": [ | |
Brian Granger
|
r6035 | "world = view.apply_async(sleep_and_echo, 3, 'World!')", | |
MinRK
|
r5981 | "hello = view.apply_async(sleep_and_echo, 2, 'Hello')" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
MinRK
|
r5981 | "prompt_number": 4 | |
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": false, | |||
MinRK
|
r5981 | "input": [ | |
Brian Granger
|
r6035 | "print \"Submitted tasks:\", hello.msg_ids, world.msg_ids", | |
MinRK
|
r5981 | "print hello.get(), world.get()" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
MinRK
|
r5981 | "outputs": [ | |
{ | |||
Brian Granger
|
r6035 | "output_type": "stream", | |
"stream": "stdout", | |||
MinRK
|
r5981 | "text": [ | |
Brian Granger
|
r6035 | "Submitted tasks: ['dd1052e0-aa75-4b25-9d35-ecbdaf6e3ed7'] ['1b46aa21-20d1-459c-bc36-2d8d03336f74']", | |
MinRK
|
r5981 | "Hello" | |
] | |||
Brian Granger
|
r6035 | }, | |
MinRK
|
r5981 | { | |
Brian Granger
|
r6035 | "output_type": "stream", | |
"stream": "stdout", | |||
MinRK
|
r5981 | "text": [ | |
" World!" | |||
] | |||
} | |||
Brian Granger
|
r6035 | ], | |
MinRK
|
r5981 | "prompt_number": 5 | |
} | |||
] | |||
} | |||
] | |||
Brian E. Granger
|
r4634 | } |