From c2fa6e5a8cc20b2386b7c6badeb3512247d5842e 2013-01-06 20:53:19 From: MinRK Date: 2013-01-06 20:53:19 Subject: [PATCH] add `%%px --local` for local execution So that a cell can be run on engines *as well as* the local namespace. Prompted by SO Question [14184621](http://stackoverflow.com/questions/14184621). --- diff --git a/IPython/parallel/client/magics.py b/IPython/parallel/client/magics.py index 9e7e22c..65f9701 100644 --- a/IPython/parallel/client/magics.py +++ b/IPython/parallel/client/magics.py @@ -70,6 +70,10 @@ def exec_args(f): magic_arguments.argument('-t', '--targets', type=str, help="specify the targets on which to execute", ), + magic_arguments.argument('--local', action="store_const", + const=True, dest="local", + help="also execute the cell in the local namespace", + ), magic_arguments.argument('--verbose', action="store_const", const=True, dest="set_verbose", help="print a message at each execution", @@ -290,6 +294,8 @@ class ParallelMagics(Magics): if args.targets: save_targets = self.view.targets self.view.targets = self._eval_target_str(args.targets) + if args.local: + self.shell.run_cell(cell) try: return self.parallel_execute(cell, block=args.block, groupby=args.groupby,