<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def get_client ( ask = True ) : <EOL> """<STR_LIT>""" <EOL> from engine_manager import EngineManager <EOL> c = EngineManager . ensure_controller ( connect_only = not ask ) <EOL> if c is not None and ask and not c . ids : <EOL> EngineManager . start_engines ( <EOL> prompt = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if c is not None and c . ids : <EOL> return c <EOL> else : <EOL> return None <EOL> def direct_view ( ask = True ) : <EOL> """<STR_LIT>""" <EOL> c = get_client ( ) <EOL> if c is not None : <EOL> return c [ : ] <EOL> else : <EOL> return None <EOL> def load_balanced_view ( ask = True ) : <EOL> """<STR_LIT>""" <EOL> c = get_client ( ) <EOL> if c is not None : <EOL> return c . load_balanced_view ( ) <EOL> else : <EOL> return None <EOL> def parallel_map ( function , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> say_ipython = kwargs . pop ( '<STR_LIT>' , False ) <EOL> ask = kwargs . pop ( '<STR_LIT>' , False ) <EOL> if kwargs : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> try : <EOL> import IPython . parallel <EOL> except ImportError : <EOL> result , ipython = map ( function , * args ) , False <EOL> else : <EOL> from engine_manager import EngineManager <EOL> c = EngineManager . ensure_controller ( connect_only = not ask ) <EOL> if c is not None and not c . ids : <EOL> EngineManager . start_engines ( <EOL> prompt = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if c is None or not c . ids : <EOL> result , ipython = map ( function , * args ) , False <EOL> else : <EOL> ldview = c . load_balanced_view ( ) <EOL> result , ipython = ldview . map_sync ( function , * args ) , True <EOL> if say_ipython : <EOL> return result , ipython <EOL> else : <EOL> return result </s>
