code: def test_database_and_get_best(generated_history):
      history, domain = generated_history
      with tempfile.TemporaryDirectory() as db_dir:
          rep = Table(
              domain,
              metrics=["metric_1", "metric_2"],
              database_path=db_dir,
          )
          best_meta, best_metrics, best_sample = {}, {}, {}
          best_score = float("-inf")
          for i, hp in enumerate(history):
              rep.log(hp, meta={"id": i})
              if hp.metrics["metric_1"].value > best_score:
                  best_meta = {"id": i}
                  best_metrics = {
                      k: {"value": v.value, "variance": v.variance}
                      for k, v in hp.metrics.items()
                  }
                  best_sample = hp.sample.as_dict()
                  best_score = hp.metrics["metric_1"].value
  
          assert len(
              rep.database.table(rep.default_database_table)
          ) == len(history)
          best_entry = rep.get_best(criterion="max")
          assert best_entry["meta"] == best_meta
          assert best_entry["metrics"] == best_metrics
          assert best_entry["sample"] == best_sample
  
          rep2 = Table(domain, metrics=["metric_1", "metric_2"])
          rep2.from_database(
              rep.database, table=rep.default_database_table
          )
          rep3 = Table(domain, metrics=["metric_1", "metric_2"])
          rep3.from_database(
              os.path.join(db_dir, "db.json"),
              table=rep.default_database_table,
          )
  
          assert str(rep) == str(rep2) == str(rep3)
          assert rep.get_best() == rep2.get_best() == rep3.get_best()
  
imports: import os
  import tempfile
  from hypertunity.optimisation.base import EvaluationScore
  from ..table import Table
label_desc: Use image node_id 3 for calling a global function with example usage: test_database_and_get_best(generated_history) without return types