Esempio n. 1
0
    def test_run_std_server(self, mock_server):
        # Arrange.
        tf_config = {
            'cluster': self._cluster_spec(),
            'task': {
                'type': run_config_lib.TaskType.PS,
                'index': 1
            }
        }
        with test.mock.patch.dict('os.environ',
                                  {'TF_CONFIG': json.dumps(tf_config)}):
            config = RunConfig(
                master='host2:2222',
                num_cores=15,
                gpu_memory_fraction=0.314,
            )
        for est in self._estimators_for_tests(config):
            ex = Experiment(est,
                            train_input_fn='train_input',
                            eval_input_fn='eval_input')

            # Act.
            ex.run_std_server()

            # Assert.
            mock_server.assert_has_calls(
                [test.mock.call().start(),
                 test.mock.call().join()])
Esempio n. 2
0
    def test_run_std_server(self, mock_server):
        # Arrange.
        tf_config = {
            'cluster': self._cluster_spec(),
            'task': {
                'type': run_config_lib.TaskType.PS,
                'index': 1
            }
        }
        with test.mock.patch.dict('os.environ',
                                  {'TF_CONFIG': json.dumps(tf_config)}):
            config = RunConfig(
                master='host2:2222',
                num_cores=15,
                gpu_memory_fraction=0.314, )
        for est in self._estimators_for_tests(config):
            ex = Experiment(
                est, train_input_fn='train_input', eval_input_fn='eval_input')

            # Act.
            ex.run_std_server()

            # Assert.
            mock_server.assert_has_calls(
                [test.mock.call().start(), test.mock.call().join()])
Esempio n. 3
0
 def test_run_std_server_raises_without_cluster_spec(self, mock_server):
     config = run_config_lib.RunConfig(master='host4:2222')
     for est in self._estimators_for_tests(config):
         with self.assertRaises(ValueError):
             ex = Experiment(est,
                             train_input_fn='train_input',
                             eval_input_fn='eval_input')
             ex.run_std_server()
Esempio n. 4
0
 def test_run_std_server_raises_without_cluster_spec(self, mock_server):
     config = run_config_lib.RunConfig(master='host4:2222')
     for est in self._estimators_for_tests(config):
         with self.assertRaises(ValueError):
             ex = Experiment(
                 est,
                 train_input_fn='train_input',
                 eval_input_fn='eval_input')
             ex.run_std_server()