當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。