def _perform_evolution(self, algo, pop): try: from IPython.kernel.client import TaskClient, MapTask # Create task client. tc = TaskClient() # Create the task. mt = MapTask(_maptask_target, args=(algo, pop)) # Run the task. task_id = tc.run(mt) # Get retval. retval = tc.get_task_result(task_id, block=True) if isinstance(retval, BaseException): raise retval return retval except BaseException as e: print('Exception caught during evolution:') print(e) raise RuntimeError()
def main(args): if args.input.isatty(): print >> sys.stderr, 'Reading from terminal. Press ^D to finish.' lines = ( l.strip() for l in iter(args.input.readline, '') ) cmds = filter(lambda k : len(k), lines) if args.verbose > 0: banner() if args.verbose > 1: for i,c in enumerate(cmds): print 'JOB %d) %s' % (i,c) try: if args.dry_run: # don't connect to controller return with catch_warnings(): simplefilter('ignore', DeprecationWarning) mec = MultiEngineClient() tc = TaskClient() _setwd(args, mec) return tc.map(execcmd, cmds) except CompositeError,e: e.print_tracebacks()