def test3_glm_random_grid_search_max_runtime_secs(self):
    '\n        This function will test the stopping criteria max_runtime_secs.  For each model built, the field\n        run_time actually denote the time in ms used to build the model.  We will add up the run_time from all\n        models and check against the stopping criteria max_runtime_secs.  Since each model will check its run time\n        differently, there is some inaccuracies in the actual run time.  For example, if we give a model 10 ms to\n        build.  The GLM may check and see if it has used up all the time for every 10 epochs that it has run.  On\n        the other hand, deeplearning may check the time it has spent after every epoch of training.\n\n        If we are able to restrict the runtime to not exceed the specified max_runtime_secs by a certain\n        percentage, we will consider the test a success.\n\n        :return: None\n        '
    print('*******************************************************************************************')
    print(('test3_glm_random_grid_search_max_runtime_secs for GLM ' + self.family))
    h2o.cluster_info()
    if ('max_runtime_secs' in list(self.hyper_params)):
        del self.hyper_params['max_runtime_secs']
        self.possible_number_models = pyunit_utils.count_models(self.hyper_params)
    max_run_time_secs = random.uniform(self.one_model_time, (self.allowed_scaled_time * self.max_grid_runtime))
    search_criteria = {'strategy': 'RandomDiscrete', 'max_runtime_secs': max_run_time_secs, 'seed': round(time.time())}
    print('GLM Gaussian grid search_criteria: {0}'.format(search_criteria))
    grid_model = H2OGridSearch(H2OGeneralizedLinearEstimator(family=self.family, nfolds=self.nfolds), hyper_params=self.hyper_params, search_criteria=search_criteria)
    grid_model.train(x=self.x_indices, y=self.y_index, training_frame=self.training1_data)
    actual_run_time_secs = pyunit_utils.find_grid_runtime(grid_model)
    print('Maximum time limit is {0}.  Time taken to build all model is {1}'.format(search_criteria['max_runtime_secs'], actual_run_time_secs))
    print('Maximum model number is {0}.  Actual number of models built is {1}'.format(self.possible_number_models, len(grid_model)))
    if (actual_run_time_secs <= (search_criteria['max_runtime_secs'] * (1 + self.allowed_diff))):
        print('test3_glm_random_grid_search_max_runtime_secs: passed!')
        if (len(grid_model) > self.possible_number_models):
            self.test_failed += 1
            self.test_failed_array[self.test_num] = 1
            print('test3_glm_random_grid_search_max_runtime_secs: failed.  Generated {0} models  which exceeds maximum possible model number {1}'.format(len(grid_model), self.possible_number_models))
    elif (len(grid_model) == 1):
        print('test3_glm_random_grid_search_max_runtime_secs: passed!')
    else:
        self.test_failed += 1
        self.test_failed_array[self.test_num] = 1
        print('test3_glm_random_grid_search_max_runtime_secs: failed.  Model takes time {0} seconds which exceeds allowed time {1}'.format(actual_run_time_secs, (max_run_time_secs * (1 + self.allowed_diff))))
    self.test_num += 1
    sys.stdout.flush()
This function will test the stopping criteria max_runtime_secs.  For each model built, the field
run_time actually denote the time in ms used to build the model.  We will add up the run_time from all
models and check against the stopping criteria max_runtime_secs.  Since each model will check its run time
differently, there is some inaccuracies in the actual run time.  For example, if we give a model 10 ms to
build.  The GLM may check and see if it has used up all the time for every 10 epochs that it has run.  On
the other hand, deeplearning may check the time it has spent after every epoch of training.

If we are able to restrict the runtime to not exceed the specified max_runtime_secs by a certain
percentage, we will consider the test a success.

:return: None
def test3_glm_random_grid_search_max_runtime_secs(self):
    '\n        This function will test the stopping criteria max_runtime_secs.  For each model built, the field\n        run_time actually denote the time in ms used to build the model.  We will add up the run_time from all\n        models and check against the stopping criteria max_runtime_secs.  Since each model will check its run time\n        differently, there is some inaccuracies in the actual run time.  For example, if we give a model 10 ms to\n        build.  The GLM may check and see if it has used up all the time for every 10 epochs that it has run.  On\n        the other hand, deeplearning may check the time it has spent after every epoch of training.\n\n        If we are able to restrict the runtime to not exceed the specified max_runtime_secs by a certain\n        percentage, we will consider the test a success.\n\n        :return: None\n        '
    print('*******************************************************************************************')
    print(('test3_glm_random_grid_search_max_runtime_secs for GLM ' + self.family))
    h2o.cluster_info()
    if ('max_runtime_secs' in list(self.hyper_params)):
        del self.hyper_params['max_runtime_secs']
        self.possible_number_models = pyunit_utils.count_models(self.hyper_params)
    max_run_time_secs = random.uniform(self.one_model_time, (self.allowed_scaled_time * self.max_grid_runtime))
    search_criteria = {'strategy': 'RandomDiscrete', 'max_runtime_secs': max_run_time_secs, 'seed': round(time.time())}
    print('GLM Gaussian grid search_criteria: {0}'.format(search_criteria))
    grid_model = H2OGridSearch(H2OGeneralizedLinearEstimator(family=self.family, nfolds=self.nfolds), hyper_params=self.hyper_params, search_criteria=search_criteria)
    grid_model.train(x=self.x_indices, y=self.y_index, training_frame=self.training1_data)
    actual_run_time_secs = pyunit_utils.find_grid_runtime(grid_model)
    print('Maximum time limit is {0}.  Time taken to build all model is {1}'.format(search_criteria['max_runtime_secs'], actual_run_time_secs))
    print('Maximum model number is {0}.  Actual number of models built is {1}'.format(self.possible_number_models, len(grid_model)))
    if (actual_run_time_secs <= (search_criteria['max_runtime_secs'] * (1 + self.allowed_diff))):
        print('test3_glm_random_grid_search_max_runtime_secs: passed!')
        if (len(grid_model) > self.possible_number_models):
            self.test_failed += 1
            self.test_failed_array[self.test_num] = 1
            print('test3_glm_random_grid_search_max_runtime_secs: failed.  Generated {0} models  which exceeds maximum possible model number {1}'.format(len(grid_model), self.possible_number_models))
    elif (len(grid_model) == 1):
        print('test3_glm_random_grid_search_max_runtime_secs: passed!')
    else:
        self.test_failed += 1
        self.test_failed_array[self.test_num] = 1
        print('test3_glm_random_grid_search_max_runtime_secs: failed.  Model takes time {0} seconds which exceeds allowed time {1}'.format(actual_run_time_secs, (max_run_time_secs * (1 + self.allowed_diff))))
    self.test_num += 1
    sys.stdout.flush()