Created
August 12, 2013 01:27
-
-
Save jrjohansson/6207703 to your computer and use it in GitHub Desktop.
test-ipython-parallel
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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "heading", | |
"level": 1, | |
"metadata": {}, | |
"source": [ | |
"Ipython 0.13.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import numpy\n", | |
"from IPython.parallel import Client" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"dview = Client()[:]; dview" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "pyout", | |
"prompt_number": 2, | |
"text": [ | |
"<DirectView [0, 1]>" | |
] | |
} | |
], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"@dview.parallel(block=True)\n", | |
"def dummy_task(delay):\n", | |
" \"\"\" a dummy task that takes 'delay' seconds to finish \"\"\"\n", | |
" import os, time\n", | |
"\n", | |
" print(delay)\n", | |
" \n", | |
" t0 = time.time()\n", | |
" pid = os.getpid()\n", | |
" time.sleep(delay)\n", | |
" t1 = time.time()\n", | |
" \n", | |
" return [pid, t0, t1]" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"dummy_task.map(numpy.random.rand(4))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "pyout", | |
"prompt_number": 4, | |
"text": [ | |
"[[25872, 1376270566.9979396, 1376270567.9623675],\n", | |
" [25872, 1376270567.9635484, 1376270567.9652116],\n", | |
" [25873, 1376270566.9979396, 1376270567.4051127],\n", | |
" [25873, 1376270567.4064236, 1376270568.215046]]" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%reload_ext version_information\n", | |
"%version_information numpy" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>Python</td><td>3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]</td></tr><tr><td>IPython</td><td>0.13.2</td></tr><tr><td>OS</td><td>posix [linux]</td></tr><tr><td>numpy</td><td>1.7.1</td></tr><tr><td colspan='2'>Mon Aug 12 10:22:48 2013 JST</td></tr></table>" | |
], | |
"json": [ | |
"{ \"Software versions\" : [{ \"module\" : \"Python\", \"version\" : \"3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]\" }, { \"module\" : \"IPython\", \"version\" : \"0.13.2\" }, { \"module\" : \"OS\", \"version\" : \"posix [linux]\" }, { \"module\" : \"numpy\", \"version\" : \"1.7.1\" } ] }" | |
], | |
"latex": [ | |
"\\begin{table}\n", | |
"\\begin{tabular}{|l|l|}\\hline\n", | |
"{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", | |
"Python & 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] \\\\ \\hline\n", | |
"IPython & 0.13.2 \\\\ \\hline\n", | |
"OS & posix [linux] \\\\ \\hline\n", | |
"numpy & 1.7.1 \\\\ \\hline\n", | |
"\\hline \\multicolumn{2}{|l|}{Mon Aug 12 10:22:48 2013 JST} \\\\ \\hline\n", | |
"\\end{tabular}\n", | |
"\\end{table}\n" | |
], | |
"output_type": "pyout", | |
"prompt_number": 5, | |
"text": [ | |
"Software versions\n", | |
"Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]\n", | |
"IPython 0.13.2\n", | |
"OS posix [linux]\n", | |
"numpy 1.7.1\n", | |
"\n", | |
"Mon Aug 12 10:22:48 2013 JST" | |
] | |
} | |
], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "heading", | |
"level": 1, | |
"metadata": {}, | |
"source": [ | |
"IPython 1.0" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import numpy" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"from IPython.parallel import Client" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"dview = Client()[:]; dview" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 3, | |
"text": [ | |
"<DirectView [0, 1]>" | |
] | |
} | |
], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"@dview.parallel(block=True)\n", | |
"def dummy_task(delay):\n", | |
" \"\"\" a dummy task that takes 'delay' seconds to finish \"\"\"\n", | |
" import os, time\n", | |
"\n", | |
" print(delay)\n", | |
" \n", | |
" t0 = time.time()\n", | |
" pid = os.getpid()\n", | |
" time.sleep(delay)\n", | |
" t1 = time.time()\n", | |
" \n", | |
" return [pid, t0, t1]" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"dummy_task.map(numpy.random.rand(4))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "ValueError", | |
"evalue": "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()", | |
"output_type": "pyerr", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-5-20b3daf6aac5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdummy_task\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrand\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[1;32m/usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py\u001b[0m in \u001b[0;36mmap\u001b[1;34m(self, *sequences)\u001b[0m\n\u001b[0;32m 275\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_mapping\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 276\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 277\u001b[1;33m \u001b[0mret\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0msequences\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 278\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 279\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_mapping\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *sequences)\u001b[0m\n", | |
"\u001b[1;32m/usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py\u001b[0m in \u001b[0;36msync_view_results\u001b[1;34m(f, self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 93\u001b[0m \u001b[0mview\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_in_sync_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 95\u001b[1;33m \u001b[0mret\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 96\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m \u001b[0mview\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_in_sync_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *sequences)\u001b[0m\n\u001b[0;32m 233\u001b[0m \u001b[0mpart\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmapObject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetPartition\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mseq\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnparts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmaxlen\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 234\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpart\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 235\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0many\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 236\u001b[0m \u001b[1;32mcontinue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 237\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mValueError\u001b[0m: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"in sync results <function ParallelFunction.__call__ at 0x7f172cc80c20>\n" | |
] | |
} | |
], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%reload_ext version_information\n", | |
"%version_information numpy" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>Python</td><td>3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]</td></tr><tr><td>IPython</td><td>1.0.0</td></tr><tr><td>OS</td><td>posix [linux]</td></tr><tr><td>numpy</td><td>1.7.1</td></tr><tr><td colspan='2'>Mon Aug 12 10:24:26 2013 JST</td></tr></table>" | |
], | |
"json": [ | |
"{ \"Software versions\" : [{ \"module\" : \"Python\", \"version\" : \"3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]\" }, { \"module\" : \"IPython\", \"version\" : \"1.0.0\" }, { \"module\" : \"OS\", \"version\" : \"posix [linux]\" }, { \"module\" : \"numpy\", \"version\" : \"1.7.1\" } ] }" | |
], | |
"latex": [ | |
"\\begin{table}\n", | |
"\\begin{tabular}{|l|l|}\\hline\n", | |
"{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", | |
"Python & 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] \\\\ \\hline\n", | |
"IPython & 1.0.0 \\\\ \\hline\n", | |
"OS & posix [linux] \\\\ \\hline\n", | |
"numpy & 1.7.1 \\\\ \\hline\n", | |
"\\hline \\multicolumn{2}{|l|}{Mon Aug 12 10:24:26 2013 JST} \\\\ \\hline\n", | |
"\\end{tabular}\n", | |
"\\end{table}\n" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 6, | |
"text": [ | |
"Software versions\n", | |
"Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3]\n", | |
"IPython 1.0.0\n", | |
"OS posix [linux]\n", | |
"numpy 1.7.1\n", | |
"\n", | |
"Mon Aug 12 10:24:26 2013 JST" | |
] | |
} | |
], | |
"prompt_number": 6 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment