當前位置: 首頁>>代碼示例>>Python>>正文


Python ipyparallel.Client方法代碼示例

本文整理匯總了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() 
開發者ID:threeML,項目名稱:threeML,代碼行數:25,代碼來源:parallel_client.py

示例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) 
開發者ID:dsavransky,項目名稱:EXOSIMS,代碼行數:32,代碼來源:IPClusterEnsemble.py

示例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."
        ) 
開發者ID:python-adaptive,項目名稱:adaptive,代碼行數:17,代碼來源:runner.py

示例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") 
開發者ID:python-adaptive,項目名稱:adaptive,代碼行數:15,代碼來源:test_runner.py

示例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 
開發者ID:python-adaptive,項目名稱:adaptive,代碼行數:10,代碼來源:test_runner.py


注:本文中的ipyparallel.Client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。