Show More
@@ -28,7 +28,7 b'' | |||
|
28 | 28 | "\n", |
|
29 | 29 | "To install dill:\n", |
|
30 | 30 | " \n", |
|
31 | " pip install dill" | |
|
31 | " pip install --pre dill" | |
|
32 | 32 | ] |
|
33 | 33 | }, |
|
34 | 34 | { |
@@ -113,7 +113,7 b'' | |||
|
113 | 113 | "outputs": [ |
|
114 | 114 | { |
|
115 | 115 | "ename": "PicklingError", |
|
116 |
"evalue": "Can't pickle <function has_closure at 0x10 |
|
|
116 | "evalue": "Can't pickle <function has_closure at 0x10412c6e0>: it's not found as __main__.has_closure", | |
|
117 | 117 | "output_type": "pyerr", |
|
118 | 118 | "traceback": [ |
|
119 | 119 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mPicklingError\u001b[0m Traceback (most recent call last)", |
@@ -122,7 +122,7 b'' | |||
|
122 | 122 | "\u001b[1;32m/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.pyc\u001b[0m in \u001b[0;36mdump\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 222\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mproto\u001b[0m \u001b[1;33m>=\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 223\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mPROTO\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mchr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mproto\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 224\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msave\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 225\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mSTOP\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 226\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", |
|
123 | 123 | "\u001b[1;32m/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.pyc\u001b[0m in \u001b[0;36msave\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 284\u001b[0m \u001b[0mf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdispatch\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 285\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 286\u001b[1;33m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# Call unbound method with explicit self\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 287\u001b[0m \u001b[1;32mreturn\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 288\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", |
|
124 | 124 | "\u001b[1;32m/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.pyc\u001b[0m in \u001b[0;36msave_global\u001b[1;34m(self, obj, name, pack)\u001b[0m\n\u001b[0;32m 746\u001b[0m raise PicklingError(\n\u001b[0;32m 747\u001b[0m \u001b[1;34m\"Can't pickle %r: it's not found as %s.%s\"\u001b[0m \u001b[1;33m%\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 748\u001b[1;33m (obj, module, name))\n\u001b[0m\u001b[0;32m 749\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 750\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mklass\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
125 |
"\u001b[1;31mPicklingError\u001b[0m: Can't pickle <function has_closure at 0x10 |
|
|
125 | "\u001b[1;31mPicklingError\u001b[0m: Can't pickle <function has_closure at 0x10412c6e0>: it's not found as __main__.has_closure" | |
|
126 | 126 | ] |
|
127 | 127 | } |
|
128 | 128 | ], |
@@ -226,12 +226,12 b'' | |||
|
226 | 226 | "\u001b[1;32m<ipython-input-9-23a646829fdc>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mview\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_sync\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mclosed\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", |
|
227 | 227 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36mapply_sync\u001b[1;34m(self, f, *args, **kwargs)\u001b[0m\n", |
|
228 | 228 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36mspin_after\u001b[1;34m(f, self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 73\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mspin_after\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[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 74\u001b[0m \u001b[1;34m\"\"\"call spin after the method.\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 75\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 76\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mspin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 77\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mret\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
229 |
"\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36mapply_sync\u001b[1;34m(self, f, *args, **kwargs)\u001b[0m\n\u001b[0;32m 24 |
|
|
229 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36mapply_sync\u001b[1;34m(self, f, *args, **kwargs)\u001b[0m\n\u001b[0;32m 245\u001b[0m \u001b[0mreturning\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 246\u001b[0m \"\"\"\n\u001b[1;32m--> 247\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_really_apply\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mblock\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 248\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 249\u001b[0m \u001b[1;31m#----------------------------------------------------------------\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
230 | 230 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36m_really_apply\u001b[1;34m(self, f, args, kwargs, block, track, after, follow, timeout, targets, retries)\u001b[0m\n", |
|
231 | 231 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36msync_results\u001b[1;34m(f, self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 64\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_in_sync_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 65\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 66\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 67\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 68\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_in_sync_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
232 | 232 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36m_really_apply\u001b[1;34m(self, f, args, kwargs, block, track, after, follow, timeout, targets, retries)\u001b[0m\n", |
|
233 | 233 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36msave_ids\u001b[1;34m(f, self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 49\u001b[0m \u001b[0mn_previous\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhistory\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 50\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 51\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 52\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 53\u001b[0m \u001b[0mnmsgs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhistory\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mn_previous\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
234 |
"\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36m_really_apply\u001b[1;34m(self, f, args, kwargs, block, track, after, follow, timeout, targets, retries)\u001b[0m\n\u001b[0;32m 10 |
|
|
234 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/view.pyc\u001b[0m in \u001b[0;36m_really_apply\u001b[1;34m(self, f, args, kwargs, block, track, after, follow, timeout, targets, retries)\u001b[0m\n\u001b[0;32m 1049\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1050\u001b[0m msg = self.client.send_apply_request(self._socket, f, args, kwargs, track=track,\n\u001b[1;32m-> 1051\u001b[1;33m metadata=metadata)\n\u001b[0m\u001b[0;32m 1052\u001b[0m \u001b[0mtracker\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mNone\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mtrack\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mFalse\u001b[0m \u001b[1;32melse\u001b[0m \u001b[0mmsg\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'tracker'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1053\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
235 | 235 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/parallel/client/client.pyc\u001b[0m in \u001b[0;36msend_apply_request\u001b[1;34m(self, socket, f, args, kwargs, metadata, track, ident)\u001b[0m\n\u001b[0;32m 1252\u001b[0m bufs = serialize.pack_apply_message(f, args, kwargs,\n\u001b[0;32m 1253\u001b[0m \u001b[0mbuffer_threshold\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msession\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuffer_threshold\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1254\u001b[1;33m \u001b[0mitem_threshold\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msession\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitem_threshold\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1255\u001b[0m )\n\u001b[0;32m 1256\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", |
|
236 | 236 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/kernel/zmq/serialize.pyc\u001b[0m in \u001b[0;36mpack_apply_message\u001b[1;34m(f, args, kwargs, buffer_threshold, item_threshold)\u001b[0m\n\u001b[0;32m 163\u001b[0m \u001b[0minfo\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnargs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnarg_bufs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg_bufs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkw_keys\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkw_keys\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 164\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 165\u001b[1;33m \u001b[0mmsg\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mpickle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\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 166\u001b[0m \u001b[0mmsg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpickle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minfo\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 167\u001b[0m \u001b[0mmsg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg_bufs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
237 | 237 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/utils/codeutil.pyc\u001b[0m in \u001b[0;36mreduce_code\u001b[1;34m(co)\u001b[0m\n\u001b[0;32m 36\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreduce_code\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mco\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 37\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_freevars\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_cellvars\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 38\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Sorry, cannot pickle code objects with closures\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 39\u001b[0m args = [co.co_argcount, co.co_nlocals, co.co_stacksize,\n\u001b[0;32m 40\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_flags\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_code\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_consts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_names\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
@@ -246,25 +246,46 b'' | |||
|
246 | 246 | "metadata": {}, |
|
247 | 247 | "source": [ |
|
248 | 248 | "Oops, no dice. For IPython to work with dill,\n", |
|
249 |
"there are one or two more steps. IPython will do these for you if you call ` |
|
|
249 | "there are one or two more steps. IPython will do these for you if you call `DirectView.use_dill`:" | |
|
250 | 250 | ] |
|
251 | 251 | }, |
|
252 | 252 | { |
|
253 | 253 | "cell_type": "code", |
|
254 | 254 | "collapsed": false, |
|
255 | 255 | "input": [ |
|
256 | "from IPython.utils import pickleutil\n", | |
|
257 | "pickleutil.use_dill()" | |
|
256 | "rc[:].use_dill()" | |
|
258 | 257 | ], |
|
259 | 258 | "language": "python", |
|
260 | 259 | "metadata": {}, |
|
261 |
"outputs": [ |
|
|
260 | "outputs": [ | |
|
261 | { | |
|
262 | "metadata": {}, | |
|
263 | "output_type": "pyout", | |
|
264 | "prompt_number": 10, | |
|
265 | "text": [ | |
|
266 | "<AsyncResult: use_dill>" | |
|
267 | ] | |
|
268 | } | |
|
269 | ], | |
|
262 | 270 | "prompt_number": 10 |
|
263 | 271 | }, |
|
264 | 272 | { |
|
265 | 273 | "cell_type": "markdown", |
|
266 | 274 | "metadata": {}, |
|
267 | 275 | "source": [ |
|
276 | "This is equivalent to\n", | |
|
277 | "\n", | |
|
278 | "```python\n", | |
|
279 | "from IPython.utils.pickleutil import use_dill\n", | |
|
280 | "use_dill()\n", | |
|
281 | "rc[:].apply(use_dill)\n", | |
|
282 | "```" | |
|
283 | ] | |
|
284 | }, | |
|
285 | { | |
|
286 | "cell_type": "markdown", | |
|
287 | "metadata": {}, | |
|
288 | "source": [ | |
|
268 | 289 | "Now let's try again" |
|
269 | 290 | ] |
|
270 | 291 | }, |
@@ -296,37 +317,25 b'' | |||
|
296 | 317 | "\n", |
|
297 | 318 | "And that's it! We can send closures and other previously non-pickleables to our engines.\n", |
|
298 | 319 | "\n", |
|
299 | "But wait, there's more!" | |
|
320 | "Let's give it a try now:" | |
|
300 | 321 | ] |
|
301 | 322 | }, |
|
302 | 323 | { |
|
303 | 324 | "cell_type": "code", |
|
304 | 325 | "collapsed": false, |
|
305 | 326 | "input": [ |
|
306 |
"view.apply_sync(make_closure, |
|
|
327 | "remote_closure = view.apply_sync(make_closure, 4)\n", | |
|
328 | "remote_closure(5)" | |
|
307 | 329 | ], |
|
308 | 330 | "language": "python", |
|
309 | 331 | "metadata": {}, |
|
310 | 332 | "outputs": [ |
|
311 | 333 | { |
|
312 | "ename": "RemoteError", | |
|
313 | "evalue": "ValueError(Sorry, cannot pickle code objects with closures)", | |
|
314 | "output_type": "pyerr", | |
|
315 |
"t |
|
|
316 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
|
317 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/kernel/zmq/serialize.pyc\u001b[0m in \u001b[0;36mserialize_object\u001b[1;34m(obj, buffer_threshold, item_threshold)\u001b[0m", | |
|
318 | "\u001b[0;32m 100\u001b[0m \u001b[0mbuffers\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_extract_buffers\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbuffer_threshold\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
319 | "\u001b[0;32m 101\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m", | |
|
320 | "\u001b[1;32m--> 102\u001b[1;33m \u001b[0mbuffers\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpickle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcobj\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
321 | "\u001b[0m\u001b[0;32m 103\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mbuffers\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
322 | "\u001b[0;32m 104\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m", | |
|
323 | "\u001b[1;32m/Users/minrk/dev/ip/mine/IPython/utils/codeutil.pyc\u001b[0m in \u001b[0;36mreduce_code\u001b[1;34m(co)\u001b[0m", | |
|
324 | "\u001b[0;32m 36\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreduce_code\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mco\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
325 | "\u001b[0;32m 37\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_freevars\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_cellvars\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
326 | "\u001b[1;32m---> 38\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Sorry, cannot pickle code objects with closures\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
327 | "\u001b[0m\u001b[0;32m 39\u001b[0m args = [co.co_argcount, co.co_nlocals, co.co_stacksize,", | |
|
328 | "\u001b[0;32m 40\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_flags\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_code\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_consts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mco\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_names\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m", | |
|
329 | "\u001b[1;31mValueError\u001b[0m: Sorry, cannot pickle code objects with closures" | |
|
334 | "metadata": {}, | |
|
335 | "output_type": "pyout", | |
|
336 | "prompt_number": 12, | |
|
337 | "text": [ | |
|
338 | "20" | |
|
330 | 339 | ] |
|
331 | 340 | } |
|
332 | 341 | ], |
@@ -336,111 +345,173 b'' | |||
|
336 | 345 | "cell_type": "markdown", |
|
337 | 346 | "metadata": {}, |
|
338 | 347 | "source": [ |
|
339 | "If we want dill support for objects coming *from* the engines,\n", | |
|
340 | "then we need to call `use_dill()` there as well.\n", | |
|
348 | "But wait, there's more!\n", | |
|
341 | 349 | "\n", |
|
342 | "`DirectView` objects have a method to call `use_dill` locally and on every engine:" | |
|
350 | "At this point, we can send/recv all kinds of stuff" | |
|
343 | 351 | ] |
|
344 | 352 | }, |
|
345 | 353 | { |
|
346 | 354 | "cell_type": "code", |
|
347 | 355 | "collapsed": false, |
|
348 | 356 | "input": [ |
|
349 | "rc[:].use_dill()" | |
|
357 | "def outer(a):\n", | |
|
358 | " def inner(b):\n", | |
|
359 | " def inner_again(c):\n", | |
|
360 | " return c * b * a\n", | |
|
361 | " return inner_again\n", | |
|
362 | " return inner" | |
|
350 | 363 | ], |
|
351 | 364 | "language": "python", |
|
352 | 365 | "metadata": {}, |
|
353 | "outputs": [ | |
|
354 | { | |
|
355 | "metadata": {}, | |
|
356 | "output_type": "pyout", | |
|
357 | "prompt_number": 13, | |
|
358 | "text": [ | |
|
359 | "<AsyncResult: use_dill>" | |
|
360 | ] | |
|
361 | } | |
|
362 | ], | |
|
366 | "outputs": [], | |
|
363 | 367 | "prompt_number": 13 |
|
364 | 368 | }, |
|
365 | 369 | { |
|
366 | 370 | "cell_type": "markdown", |
|
367 | 371 | "metadata": {}, |
|
368 | 372 | "source": [ |
|
369 | "This is equivalent to\n", | |
|
373 | "So outer returns a function with a closure, which returns a function with a closure.\n", | |
|
370 | 374 | "\n", |
|
371 | "```python\n", | |
|
372 | "from IPython.utils.pickleutil import use_dill\n", | |
|
373 | "use_dill()\n", | |
|
374 | "rc[:].apply(use_dill)\n", | |
|
375 | "```" | |
|
375 | "Now, we can resolve the first closure on the engine, the second here, and the third on a different engine,\n", | |
|
376 | "after passing through a lambda we define here and call there, just for good measure." | |
|
376 | 377 | ] |
|
377 | 378 | }, |
|
378 | 379 | { |
|
380 | "cell_type": "code", | |
|
381 | "collapsed": false, | |
|
382 | "input": [ | |
|
383 | "view.apply_sync(lambda f: f(3),view.apply_sync(outer, 1)(2))" | |
|
384 | ], | |
|
385 | "language": "python", | |
|
386 | "metadata": {}, | |
|
387 | "outputs": [ | |
|
388 | { | |
|
389 | "metadata": {}, | |
|
390 | "output_type": "pyout", | |
|
391 | "prompt_number": 14, | |
|
392 | "text": [ | |
|
393 | "6" | |
|
394 | ] | |
|
395 | } | |
|
396 | ], | |
|
397 | "prompt_number": 14 | |
|
398 | }, | |
|
399 | { | |
|
379 | 400 | "cell_type": "markdown", |
|
380 | 401 | "metadata": {}, |
|
381 | 402 | "source": [ |
|
382 | "Let's give it a try now:" | |
|
403 | "And for good measure, let's test that normal execution still works:" | |
|
383 | 404 | ] |
|
384 | 405 | }, |
|
385 | 406 | { |
|
386 | 407 | "cell_type": "code", |
|
387 | 408 | "collapsed": false, |
|
388 | 409 | "input": [ |
|
389 | "remote_closure = view.apply_sync(make_closure, 4)\n", | |
|
390 | "remote_closure(5)" | |
|
410 | "%px foo = 5\n", | |
|
411 | "\n", | |
|
412 | "print(rc[:]['foo'])\n", | |
|
413 | "rc[:]['bar'] = lambda : 2 * foo\n", | |
|
414 | "rc[:].apply_sync(parallel.Reference('bar'))" | |
|
391 | 415 | ], |
|
392 | 416 | "language": "python", |
|
393 | 417 | "metadata": {}, |
|
394 | 418 | "outputs": [ |
|
395 | 419 | { |
|
420 | "output_type": "stream", | |
|
421 | "stream": "stdout", | |
|
422 | "text": [ | |
|
423 | "[5, 5, 5, 5, 5, 5, 5, 5]\n" | |
|
424 | ] | |
|
425 | }, | |
|
426 | { | |
|
396 | 427 | "metadata": {}, |
|
397 | 428 | "output_type": "pyout", |
|
398 |
"prompt_number": 1 |
|
|
429 | "prompt_number": 15, | |
|
399 | 430 | "text": [ |
|
400 | "20" | |
|
431 | "[10, 10, 10, 10, 10, 10, 10, 10]" | |
|
401 | 432 | ] |
|
402 | 433 | } |
|
403 | 434 | ], |
|
404 |
"prompt_number": 1 |
|
|
435 | "prompt_number": 15 | |
|
405 | 436 | }, |
|
406 | 437 | { |
|
407 | 438 | "cell_type": "markdown", |
|
408 | 439 | "metadata": {}, |
|
409 | 440 | "source": [ |
|
410 | "At this point, we can send/recv all kinds of stuff" | |
|
441 | "And test that the `@interactive` decorator works" | |
|
411 | 442 | ] |
|
412 | 443 | }, |
|
413 | 444 | { |
|
414 | 445 | "cell_type": "code", |
|
415 | 446 | "collapsed": false, |
|
416 | 447 | "input": [ |
|
417 | "def outer(a):\n", | |
|
418 | " def inner(b):\n", | |
|
419 | " def inner_again(c):\n", | |
|
420 | " return c * b * a\n", | |
|
421 | " return inner_again\n", | |
|
422 | " return inner" | |
|
448 | "%%file testdill.py\n", | |
|
449 | "from IPython.parallel import interactive\n", | |
|
450 | "\n", | |
|
451 | "@interactive\n", | |
|
452 | "class C(object):\n", | |
|
453 | " a = 5\n", | |
|
454 | "\n", | |
|
455 | "@interactive\n", | |
|
456 | "class D(C):\n", | |
|
457 | " b = 10\n", | |
|
458 | "\n", | |
|
459 | "@interactive\n", | |
|
460 | "def foo(a):\n", | |
|
461 | " return a * b\n" | |
|
462 | ], | |
|
463 | "language": "python", | |
|
464 | "metadata": {}, | |
|
465 | "outputs": [ | |
|
466 | { | |
|
467 | "output_type": "stream", | |
|
468 | "stream": "stdout", | |
|
469 | "text": [ | |
|
470 | "Overwriting testdill.py\n" | |
|
471 | ] | |
|
472 | } | |
|
473 | ], | |
|
474 | "prompt_number": 16 | |
|
475 | }, | |
|
476 | { | |
|
477 | "cell_type": "code", | |
|
478 | "collapsed": false, | |
|
479 | "input": [ | |
|
480 | "import testdill" | |
|
423 | 481 | ], |
|
424 | 482 | "language": "python", |
|
425 | 483 | "metadata": {}, |
|
426 | 484 | "outputs": [], |
|
427 |
"prompt_number": 1 |
|
|
485 | "prompt_number": 17 | |
|
428 | 486 | }, |
|
429 | 487 | { |
|
430 |
"cell_type": " |
|
|
488 | "cell_type": "code", | |
|
489 | "collapsed": false, | |
|
490 | "input": [ | |
|
491 | "v = rc[-1]\n", | |
|
492 | "v['D'] = testdill.D\n", | |
|
493 | "d = v.apply_sync(lambda : D())\n", | |
|
494 | "print d.a, d.b" | |
|
495 | ], | |
|
496 | "language": "python", | |
|
431 | 497 | "metadata": {}, |
|
432 |
" |
|
|
433 | "So outer returns a function with a closure, which returns a function with a closure.\n", | |
|
434 | "\n", | |
|
435 | "Now, we can resolve the first closure on the engine, the second here, and the third on a different engine,\n", | |
|
436 | "after passing through a lambda we define here and call there, just for good measure." | |
|
437 | ] | |
|
498 | "outputs": [ | |
|
499 | { | |
|
500 | "output_type": "stream", | |
|
501 | "stream": "stdout", | |
|
502 | "text": [ | |
|
503 | "5 10\n" | |
|
504 | ] | |
|
505 | } | |
|
506 | ], | |
|
507 | "prompt_number": 18 | |
|
438 | 508 | }, |
|
439 | 509 | { |
|
440 | 510 | "cell_type": "code", |
|
441 | 511 | "collapsed": false, |
|
442 | 512 | "input": [ |
|
443 | "view.apply_sync(lambda f: f(3),view.apply_sync(outer, 1)(2))" | |
|
513 | "v['b'] = 10\n", | |
|
514 | "v.apply_sync(testdill.foo, 5)" | |
|
444 | 515 | ], |
|
445 | 516 | "language": "python", |
|
446 | 517 | "metadata": {}, |
@@ -448,13 +519,13 b'' | |||
|
448 | 519 | { |
|
449 | 520 | "metadata": {}, |
|
450 | 521 | "output_type": "pyout", |
|
451 |
"prompt_number": 1 |
|
|
522 | "prompt_number": 19, | |
|
452 | 523 | "text": [ |
|
453 |
" |
|
|
524 | "50" | |
|
454 | 525 | ] |
|
455 | 526 | } |
|
456 | 527 | ], |
|
457 |
"prompt_number": 1 |
|
|
528 | "prompt_number": 19 | |
|
458 | 529 | } |
|
459 | 530 | ], |
|
460 | 531 | "metadata": {} |
General Comments 0
You need to be logged in to leave comments.
Login now