本文整理汇总了Python中ipyparallel.Client方法的典型用法代码示例。如果您正苦于以下问题:Python ipyparallel.Client方法的具体用法?Python ipyparallel.Client怎么用?Python ipyparallel.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipyparallel
的用法示例。
在下文中一共展示了ipyparallel.Client方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import ipyparallel [as 别名]
# 或者: from ipyparallel import Client [as 别名]
def __init__(self, *args, **kwargs):
"""
Wrapper around the IPython Client class, which forces the use of dill for object serialization
:param args: same as IPython Client
:param kwargs: same as IPython Client
:return:
"""
# Just a wrapper around the IPython Client class
# forcing the use of dill for object serialization
# (more robust, and allows for serialization of class
# methods)
if "profile" not in kwargs.keys():
kwargs["profile"] = threeML_config["parallel"]["IPython profile name"]
super(ParallelClient, self).__init__(*args, **kwargs)
# This will propagate the use_dill to all running
# engines
_ = self.direct_view().use_dill()
示例2: __init__
# 需要导入模块: import ipyparallel [as 别名]
# 或者: from ipyparallel import Client [as 别名]
def __init__(self, **specs):
SurveyEnsemble.__init__(self, **specs)
self.verb = specs.get('verbose', True)
# access the cluster
self.rc = Client()
self.dview = self.rc[:]
self.dview.block = True
with self.dview.sync_imports(): import EXOSIMS, EXOSIMS.util.get_module, \
os, os.path, time, random, pickle, traceback, numpy
if 'logger' in specs:
specs.pop('logger')
if 'seed' in specs:
specs.pop('seed')
self.dview.push(dict(specs=specs))
self.vprint("Building SurveySimulation object on all workers.")
res = self.dview.execute("SS = EXOSIMS.util.get_module.get_module(specs['modules'] \
['SurveySimulation'], 'SurveySimulation')(**specs)")
res2 = self.dview.execute("SS.reset_sim()")
self.vprint("Created SurveySimulation objects on %d engines."%len(self.rc.ids))
#for row in res.stdout:
# self.vprint(row)
self.lview = self.rc.load_balanced_view()
self.maxNumEngines = len(self.rc.ids)
示例3: _ensure_executor
# 需要导入模块: import ipyparallel [as 别名]
# 或者: from ipyparallel import Client [as 别名]
def _ensure_executor(executor):
if executor is None:
executor = _default_executor()
if isinstance(executor, concurrent.Executor):
return executor
elif with_ipyparallel and isinstance(executor, ipyparallel.Client):
return executor.executor()
elif with_distributed and isinstance(executor, distributed.Client):
return executor.get_executor()
else:
raise TypeError(
"Only a concurrent.futures.Executor, distributed.Client,"
" or ipyparallel.Client can be used."
)
示例4: ipyparallel_executor
# 需要导入模块: import ipyparallel [as 别名]
# 或者: from ipyparallel import Client [as 别名]
def ipyparallel_executor():
from ipyparallel import Client
if os.name == "nt":
import wexpect as expect
else:
import pexpect as expect
child = expect.spawn("ipcluster start -n 1")
child.expect("Engines appear to have started successfully", timeout=35)
yield Client()
if not child.terminate(force=True):
raise RuntimeError("Could not stop ipcluster")
示例5: test_distributed_executor
# 需要导入模块: import ipyparallel [as 别名]
# 或者: from ipyparallel import Client [as 别名]
def test_distributed_executor():
from distributed import Client
learner = Learner1D(linear, (-1, 1))
client = Client(n_workers=1)
BlockingRunner(learner, trivial_goal, executor=client)
client.shutdown()
assert learner.npoints > 0