Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworking parallel examples as notebooks.
- Loading branch information
Showing
11 changed files
with
2,525 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<notebook> | ||
<name>helloworld</name> | ||
<nbformat>2</nbformat> | ||
<worksheets> | ||
<worksheet> | ||
<cells> | ||
<markdowncell> | ||
<source># Distributed hello world | ||
|
||
Originally by Ken Kinder (ken at kenkinder dom com)</source> | ||
</markdowncell> | ||
<codecell> | ||
<input>from IPython.parallel import Client</input> | ||
<language>python</language> | ||
<prompt_number>3</prompt_number> | ||
<collapsed>1</collapsed> | ||
<outputs /> | ||
</codecell> | ||
<codecell> | ||
<input>rc = Client() | ||
view = rc.load_balanced_view()</input> | ||
<language>python</language> | ||
<prompt_number>4</prompt_number> | ||
<collapsed>1</collapsed> | ||
<outputs /> | ||
</codecell> | ||
<codecell> | ||
<input>def sleep_and_echo(t, msg): | ||
import time | ||
time.sleep(t) | ||
return msg</input> | ||
<language>python</language> | ||
<prompt_number>5</prompt_number> | ||
<collapsed>1</collapsed> | ||
<outputs /> | ||
</codecell> | ||
<codecell> | ||
<input>world = view.apply_async(sleep_and_echo, 3, 'World!') | ||
hello = view.apply_async(sleep_and_echo, 2, 'Hello') | ||
</input> | ||
<language>python</language> | ||
<prompt_number>6</prompt_number> | ||
<collapsed>1</collapsed> | ||
<outputs /> | ||
</codecell> | ||
<codecell> | ||
<input>print "Submitted tasks:", hello.msg_ids, world.msg_ids | ||
print hello.get(), world.get()</input> | ||
<language>python</language> | ||
<prompt_number>7</prompt_number> | ||
<collapsed>0</collapsed> | ||
<outputs> | ||
<output> | ||
<output_type>stream</output_type> | ||
<text>Submitted tasks: [&apos;9e533683-d54e-4588-929e-984dd3eb6dc4&apos;] [&apos;90395f15-723f-44df-a743-a5d88cdeb6a0&apos;] | ||
Hello</text> | ||
</output> | ||
<output> | ||
<output_type>stream</output_type> | ||
<text>World!</text> | ||
</output> | ||
</outputs> | ||
</codecell> | ||
</cells> | ||
</worksheet> | ||
</worksheets> | ||
</notebook> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
""" | ||
A Distributed Hello world | ||
Ken Kinder <ken@kenkinder.com> | ||
""" | ||
# <nbformat>2</nbformat> | ||
|
||
# <markdowncell> | ||
|
||
# # Distributed hello world | ||
# | ||
# Originally by Ken Kinder (ken at kenkinder dom com) | ||
|
||
# <codecell> | ||
|
||
from IPython.parallel import Client | ||
|
||
# <codecell> | ||
|
||
rc = Client() | ||
view = rc.load_balanced_view() | ||
|
||
# <codecell> | ||
|
||
def sleep_and_echo(t, msg): | ||
import time | ||
time.sleep(t) | ||
return msg | ||
view = rc.load_balanced_view() | ||
|
||
# <codecell> | ||
|
||
world = view.apply_async(sleep_and_echo, 3, 'World!') | ||
hello = view.apply_async(sleep_and_echo, 2, 'Hello') | ||
|
||
# <codecell> | ||
|
||
print "Submitted tasks:", hello.msg_ids, world.msg_ids | ||
print hello.get(), world.get() | ||
|
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.