当前位置: 首页>>代码示例>>Python>>正文


Python nameserver.nic_name_to_host方法代码示例

本文整理汇总了Python中hpbandster.core.nameserver.nic_name_to_host方法的典型用法代码示例。如果您正苦于以下问题:Python nameserver.nic_name_to_host方法的具体用法?Python nameserver.nic_name_to_host怎么用?Python nameserver.nic_name_to_host使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hpbandster.core.nameserver的用法示例。


在下文中一共展示了nameserver.nic_name_to_host方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_worker

# 需要导入模块: from hpbandster.core import nameserver [as 别名]
# 或者: from hpbandster.core.nameserver import nic_name_to_host [as 别名]
def run_worker(self, pipeline_config, constant_hyperparameter, run_id, task_id, ns_credentials_dir, network_interface_name,
            X_train, Y_train, X_valid, Y_valid):
        if not task_id == -1:
            time.sleep(5)
        while not os.path.isdir(ns_credentials_dir):
            time.sleep(5)
        host = nic_name_to_host(network_interface_name)
        
        worker = ModuleWorkerNoTimeLimit(   pipeline=self.sub_pipeline, pipeline_config=pipeline_config,
                                            constant_hyperparameter=constant_hyperparameter,
                                            X_train=X_train, Y_train=Y_train, X_valid=X_valid, Y_valid=Y_valid, 
                                            budget_type=pipeline_config['budget_type'],
                                            max_budget=pipeline_config["max_budget"],
                                            host=host, run_id=run_id,
                                            id=task_id,
                                            working_directory=pipeline_config["result_logger_dir"],
                                            permutations=self.permutations)
        worker.load_nameserver_credentials(ns_credentials_dir)
        # run in background if not on cluster
        worker.run(background=(task_id <= 1)) 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:22,代码来源:optimization_algorithm_no_timelimit.py

示例2: test_Timeout

# 需要导入模块: from hpbandster.core import nameserver [as 别名]
# 或者: from hpbandster.core.nameserver import nic_name_to_host [as 别名]
def test_Timeout(self):
        class dummy_callback(object):
            def register_result(self, *args, **kwargs):
                pass

        host = hpn.nic_name_to_host('lo')

        w = TestWorker(run_id=self.run_id, sleep_duration=0, timeout=1, host=host)

        dc = dummy_callback()

        with tempfile.TemporaryDirectory() as working_directory:
            # start up nameserver
            ns = hpn.NameServer(self.run_id, working_directory=working_directory, host=host)
            ns_host, ns_port = ns.start()

            # connect worker to it
            w.load_nameserver_credentials(working_directory)
            w.run(background=True)

            # start a computation with a dummy callback and dummy id
            w.start_computation(dc, '0')

            # at this point the worker must still be alive
            self.assertTrue(w.thread.is_alive())

            # as the timeout is only 1, after 2 seconds, the worker thread should be dead
            time.sleep(2)
            self.assertFalse(w.thread.is_alive())

            # shutdown the nameserver before the temporary directory is gone
            ns.shutdown() 
开发者ID:automl,项目名称:HpBandSter,代码行数:34,代码来源:test_worker.py

示例3: test_optimizers

# 需要导入模块: from hpbandster.core import nameserver [as 别名]
# 或者: from hpbandster.core.nameserver import nic_name_to_host [as 别名]
def test_optimizers(self):
        optimizers = [BOHB, H2BO, RandomSearch]

        for optimizer in optimizers:
            host = hpn.nic_name_to_host('lo')

            with tempfile.TemporaryDirectory() as working_directory:
                # start up nameserver
                ns = hpn.NameServer(self.run_id, working_directory=working_directory, host=host)
                ns_host, ns_port = ns.start()

                # create workers and connect them to the nameserver
                w = TestWorker(run_id=self.run_id, sleep_duration=2, timeout=1, host=host, id=1)
                w.load_nameserver_credentials(working_directory)
                w.run(background=True)

                opt = optimizer(run_id=self.run_id,
                                configspace=self.configspace,
                                nameserver=ns_host,
                                nameserver_port=ns_port,
                                min_budget=1, max_budget=3, eta=3, ping_interval=1)
                opt.run(1, min_n_workers=1)

                opt.shutdown()
                time.sleep(2)

                # shutdown the nameserver before the temporary directory is gone
                ns.shutdown() 
开发者ID:automl,项目名称:HpBandSter,代码行数:30,代码来源:test_worker.py

示例4: run_worker

# 需要导入模块: from hpbandster.core import nameserver [as 别名]
# 或者: from hpbandster.core.nameserver import nic_name_to_host [as 别名]
def run_worker(self, pipeline_config, run_id, task_id, ns_credentials_dir, network_interface_name,
            X_train, Y_train, X_valid, Y_valid, dataset_info, shutdownables):
        """ Run the AutoNetWorker
        
        Arguments:
            pipeline_config {dict} -- The configuration of the pipeline
            run_id {str} -- An id for the run
            task_id {int} -- An id for the worker
            ns_credentials_dir {str} -- path to nameserver credentials
            network_interface_name {str} -- the name of the network interface
            X_train {array} -- The data
            Y_train {array} -- The data
            X_valid {array} -- The data
            Y_valid {array} -- The data
            dataset_info {DatasetInfo} -- Object describing the dataset
            shutdownables {list} -- A list of objects that need to shutdown when the optimization is finished
        """
        if not task_id == -1:
            time.sleep(5)
        while not os.path.isdir(ns_credentials_dir):
            time.sleep(5)
        host = nic_name_to_host(network_interface_name)
        
        worker = AutoNetWorker(pipeline=self.sub_pipeline, pipeline_config=pipeline_config,
                              X_train=X_train, Y_train=Y_train, X_valid=X_valid, Y_valid=Y_valid, dataset_info=dataset_info,
                              budget_type=self.budget_types[pipeline_config['budget_type']],
                              max_budget=pipeline_config["max_budget"],
                              host=host, run_id=run_id,
                              id=task_id, shutdownables=shutdownables,
                              use_pynisher=pipeline_config["use_pynisher"])
        worker.load_nameserver_credentials(ns_credentials_dir)
        # run in background if not on cluster
        worker.run(background=(task_id <= 1)) 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:35,代码来源:optimization_algorithm.py

示例5: fit

# 需要导入模块: from hpbandster.core import nameserver [as 别名]
# 或者: from hpbandster.core.nameserver import nic_name_to_host [as 别名]
def fit(self, pipeline_config, result_loggers, shutdownables, refit=False):
        if refit or pipeline_config["ensemble_size"] == 0:
            return dict()
        es_credentials_file = os.path.join(pipeline_config["working_dir"], "es_credentials_%s.json" % pipeline_config["run_id"])

        # start server
        if pipeline_config["task_id"] != 1 or pipeline_config["run_worker_on_master_node"]:
            host = nic_name_to_host(OptimizationAlgorithm.get_nic_name(pipeline_config))
            host, port, process = start_server(host)
            pipeline_config["ensemble_server_credentials"] = (host, port)
            shutdownables = shutdownables + [process]

        result_loggers = [ensemble_logger(directory=pipeline_config["result_logger_dir"], overwrite=True)] + result_loggers
        return {"result_loggers": result_loggers, "shutdownables": shutdownables} 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:16,代码来源:ensemble.py


注:本文中的hpbandster.core.nameserver.nic_name_to_host方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。