Skip to content

Commit

Permalink
Reworking parallel examples as notebooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonbg committed Aug 16, 2011
1 parent f6078d0 commit 3ec3b24
Show file tree
Hide file tree
Showing 11 changed files with 2,525 additions and 54 deletions.
1 change: 0 additions & 1 deletion IPython/core/magic.py
Expand Up @@ -3530,7 +3530,6 @@ def magic_notebook(self, s):
formats include (xml/ipynb, json, py).
"""
args = magic_arguments.parse_argstring(self.magic_notebook, s)
print args

from IPython.nbformat import current
if args.export:
Expand Down
68 changes: 68 additions & 0 deletions docs/examples/newparallel/helloworld.ipynb
@@ -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: [&amp;apos;9e533683-d54e-4588-929e-984dd3eb6dc4&amp;apos;] [&amp;apos;90395f15-723f-44df-a743-a5d88cdeb6a0&amp;apos;]
Hello</text>
</output>
<output>
<output_type>stream</output_type>
<text>World!</text>
</output>
</outputs>
</codecell>
</cells>
</worksheet>
</worksheets>
</notebook>
27 changes: 21 additions & 6 deletions docs/examples/newparallel/helloworld.py
@@ -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()

45 changes: 0 additions & 45 deletions docs/examples/newparallel/mcpricer.py

This file was deleted.

File renamed without changes.

0 comments on commit 3ec3b24

Please sign in to comment.