def continuous_eval(eval_dataset, estimator, mention2text, entityid2name,
                    supervision, eval_fn, **kwargs):
  """Run continuous evaluation on given TFRecords file."""
  current_ckpt = 0
  best_acc = 0
  stop_evaluating = False
  if not tf.gfile.Exists(os.path.join(FLAGS.output_dir, "eval")):
    tf.gfile.MakeDirs(os.path.join(FLAGS.output_dir, "eval"))
  event_writer = tf.summary.FileWriter(os.path.join(FLAGS.output_dir, "eval"))
  while not stop_evaluating:
    if FLAGS.use_best_ckpt_for_predict:
      ckpt_path = os.path.join(FLAGS.output_dir, "best_model")
      if not os.path.exists(ckpt_path + ".meta"):
        tf.logging.info("No best_model checkpoint found in %s",
                        FLAGS.output_dir)
        tf.logging.info("Skipping evaluation.")
        break
      output_prediction_file = os.path.join(FLAGS.output_dir,
                                            "predictions.json")
      stop_evaluating = True
    else:
      ckpt_path = tf.train.latest_checkpoint(FLAGS.output_dir)
      if ckpt_path == current_ckpt:
        tf.logging.info("No new checkpoint in %s", FLAGS.output_dir)
        tf.logging.info("Waiting for 100s")
        time.sleep(100)
        continue
      current_ckpt = ckpt_path
      model_name = None
      if ckpt_path is not None:
        model_name = os.path.basename(ckpt_path)
      output_prediction_file = os.path.join(FLAGS.output_dir,
                                            "predictions_%s.json" % model_name)

    metrics = single_eval(eval_dataset, estimator, ckpt_path, mention2text,
                          entityid2name, supervision, output_prediction_file,
                          eval_fn, **kwargs)

    if ckpt_path is not None:
      ckpt_number = int(ckpt_path.rsplit("-", 1)[1])
      if metrics["accuracy"] > best_acc:
        best_acc = metrics["accuracy"]
        if tf.gfile.Exists(ckpt_path + ".meta"):
          _copy_model(ckpt_path, os.path.join(FLAGS.output_dir, "best_model"))
    else:
      ckpt_number = 0
    for metric, value in metrics.items():
      tf.logging.info("%s: %.4f", metric, value)
      curr_summary = tf.Summary(value=[
          tf.Summary.Value(tag=metric, simple_value=value),
      ])
      event_writer.add_summary(curr_summary, global_step=ckpt_number)
Run continuous evaluation on given TFRecords file.
language/labs/drkit/run_multihop_follow.py