class_docstr: This class is created to test the three stopping conditions for randomized gridsearch using
  GLM Binomial family.  The three stopping conditions are :
  
  1. max_runtime_secs:
  2. max_models:
  3. metrics.  We will be picking 2 stopping metrics to test this stopping condition with.  One metric
  will be optimized if it increases and the other one should be optimized if it decreases.
  
  I have written 4 tests:
  1. test1_glm_random_grid_search_model_number: this test will not put any stopping conditions
  on randomized search.  The purpose here is to make sure that randomized search will give us all possible
  hyper-parameter combinations.
  2. test2_glm_random_grid_search_max_model: this test the stopping condition of setting the max_model in
  search criteria;
  3. test3_glm_random_grid_search_max_runtime_secs: this test the stopping condition max_runtime_secs
  in search criteria;
  4. test4_glm_random_grid_search_metric: this test the stopping condition of using a metric which can be
  increasing or decreasing.
class_docstr_tok: ["This","class","is","created","to","test","the","three","stopping","conditions","for","randomized","gridsearch","using","GLM","Binomial","family",".","The","three","stopping","conditions","are",":","1.","max_runtime_secs",":","2.","max_models",":","3.","metrics",".","We","will","be","picking","2","stopping","metrics","to","test","this","stopping","condition","with",".","One","metric","will","be","optimized","if","it","increases","and","the","other","one","should","be","optimized","if","it","decreases",".","I","have","written","4","tests",":","1.","test1_glm_random_grid_search_model_number",":","this","test","will","not","put","any","stopping","conditions","on","randomized","search",".","The","purpose","here","is","to","make","sure","that","randomized","search","will","give","us","all","possible","hyper-parameter","combinations",".","2.","test2_glm_random_grid_search_max_model",":","this","test","the","stopping","condition","of","setting","the","max_model","in","search","criteria",";","3.","test3_glm_random_grid_search_max_runtime_secs",":","this","test","the","stopping","condition","max_runtime_secs","in","search","criteria",";","4.","test4_glm_random_grid_search_metric",":","this","test","the","stopping","condition","of","using","a","metric","which","can","be","increasing","or","decreasing","."]
docstr: This function performs teardown after the dynamic test is completed.  If all tests
  passed, it will delete all data sets generated since they can be quite large.  It
  will move the training/validation/test data sets into a Rsandbox directory so that
  we can re-run the failed test.
docstr_tok: ["This","function","performs","teardown","after","the","dynamic","test","is","completed",".","If","all","tests","passed",",","it","will","delete","all","data","sets","generated","since","they","can","be","quite","large",".","It","will","move","the","training\/validation\/test","data","sets","into","a","Rsandbox","directory","so","that","we","can","re-run","the","failed","test","."]
code: def tear_down(self):
      """
      This function performs teardown after the dynamic test is completed.  If all tests
      passed, it will delete all data sets generated since they can be quite large.  It
      will move the training/validation/test data sets into a Rsandbox directory so that
      we can re-run the failed test.
      """
  
      if (
          self.test_failed
      ):  # some tests have failed.  Need to save data sets for later re-runs
          # create Rsandbox directory to keep data sets and weight information
          self.sandbox_dir = pyunit_utils.make_Rsandbox_dir(
              self.current_dir, self.test_name, True
          )
  
          # Do not want to save all data sets.  Only save data sets that are needed for failed tests
          pyunit_utils.move_files(
              self.sandbox_dir,
              self.training1_data_file,
              self.training1_filename,
          )
  
          # write out the jenkins job info into log files.
          json_file = os.path.join(self.sandbox_dir, self.json_filename)
  
          with open(json_file, "wb") as test_file:
              json.dump(self.hyper_params, test_file)
  
      else:  # all tests have passed.  Delete sandbox if if was not wiped before
          pyunit_utils.make_Rsandbox_dir(
              self.current_dir, self.test_name, False
          )
  
file_path: h2o-3/h2o-py/dynamic_tests/testdir_algos/glm/pyunit_glm_binomial_gridsearch_randomdiscrete_large.py
imports: import sys
  import random
  import os
  from builtins import range
  import time
  import json
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.glm import H2OGeneralizedLinearEstimator
  from h2o.grid.grid_search import H2OGridSearch
label_desc: Use image node_id 4 for calling the Test_glm_random_grid_search obj's underlying member method code with example usage: obj.tear_down() without return types