class_docstr: Dictionary which specifies all that's needed to build and validate a grid of models.
class_docstr_tok: ["Dictionary","which","specifies","all","that","'s","needed","to","build","and","validate","a","grid","of","models","."]
code: def build_and_validate_grid(self, a_node):
      before = time.time()
      if isVerbose():
          print(
              "About to build: "
              + self["dest_key"]
              + ", a "
              + self["algo"]
              + " model grid on frame: "
              + self["frame_key"]
              + " with params: "
              + repr(self["params"])
              + " and grid_params: "
              + repr(self["grid_params"])
          )
  
      # returns a GridSearchSchema:
      result = a_node.build_model_grid(
          algo=self["algo"],
          grid_id=self["dest_key"],
          training_frame=self["frame_key"],
          parameters=self["params"],
          grid_parameters=self["grid_params"],
          search_criteria=self["search_criteria"],
          timeoutSecs=240,
      )  # synchronous
      if isVerboser():
          print("result: " + repr(result))
      grid = a_node.grid(key=self["dest_key"])
      if isVerboser():
          print("grid: " + repr(grid))
  
      validate_grid_builder_result(
          grid, self["params"], self["grid_params"], self["dest_key"]
      )
  
      # print("grid result: " + repr(grid))
      # print("grid __meta: " + repr(grid['__meta']))
      for model_key_dict in grid["model_ids"]:
          model_key = model_key_dict["name"]
          model = validate_model_exists(a_node, model_key)
          validate_actual_parameters(
              self["params"],
              model["parameters"],
              self["frame_key"],
              None,
          )
          validate_grid_parameters(
              self["grid_params"], model["parameters"]
          )
  
          assert "output" in model, (
              "FAIL: Failed to find output object in model: "
              + self["dest_key"]
          )
          assert "model_category" in model["output"], (
              "FAIL: Failed to find model_category in model: "
              + self["dest_key"]
          )
          assert (
              model["output"]["model_category"]
              == self["model_category"]
          ), (
              "FAIL: Expected model_category: "
              + self["model_category"]
              + " but got: "
              + model["output"]["model_category"]
              + " for model: "
              + self["dest_key"]
          )
  
      # Cartesian or random with max_models: check that we got the right number of models if we know beforehand:
      combos = 1
      for k, vals in self["grid_params"].items():
          combos *= len(vals)
  
      # NOTE: if we have a stopping critereon which is not a fixed number we don't know how many models to expect
      expected = None
      if (
          self["search_criteria"] is None
          or self["search_criteria"]["strategy"] is "Cartesian"
      ):
          expected = combos
      elif (
          self["search_criteria"] is not None
          and "max_models" in self["search_criteria"]
          and "max_time_ms" not in self["search_criteria"]
      ):
          expected = min(combos, self["search_criteria"]["max_models"])
  
      if expected is not None:
          assert expected == len(grid["model_ids"]), (
              "FAIL: Expected "
              + str(expected)
              + " models; got: "
              + str(len(grid["model_ids"]))
          )
  
      if isVerbose():
          print(
              "Done building: "
              + self["dest_key"]
              + " ("
              + str(time.time() - before)
              + ")"
          )
      return grid
  
imports: import sys, os, time, json, datetime, errno, stat, getpass, requests, pprint
  import h2o
label_desc: Use image node_id 3 for calling the GridSpec obj's underlying member method code with example usage: obj.build_and_validate_grid(a_node) and returns: grid