Runs Eval once.

  Args:
    saver: Saver.
    summary_writer: Summary writer.
    top_1_op: Top 1 op.
    top_5_op: Top 5 op.
    summary_op: Summary op.
6281
def _eval_once(saver, summary_writer, top_1_op, top_5_op, summary_op):
  
  with tf.Session() as sess:
    ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
    if ckpt and ckpt.model_checkpoint_path:
      print("ckpt.model_checkpoint_path: {0}".format(ckpt.model_checkpoint_path))
      saver.restore(sess, ckpt.model_checkpoint_path)

      # Assuming model_checkpoint_path looks something like:
      #   /my-favorite-path/imagenet_train/model.ckpt-0,
      # extract global_step from it.
      global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
      print('Successfully loaded model from %s at step=%s.' %
            (ckpt.model_checkpoint_path, global_step))
    else:
      print('No checkpoint file found')
      return

    # Start the queue runners.
    coord = tf.train.Coordinator()
    try:
      threads = []
      for qr in tf.get_collection(tf.GraphKeys.QUEUE_RUNNERS):
        threads.extend(qr.create_threads(sess, coord=coord, daemon=True,
                                         start=True))

      num_iter = int(math.ceil(FLAGS.num_examples / FLAGS.batch_size))
      # Counts the number of correct predictions.
      count_top_1 = 0.0
      count_top_5 = 0.0
      total_sample_count = num_iter * FLAGS.batch_size
      step = 0

      print('%s: starting evaluation on (%s).' % (datetime.now(), FLAGS.subset))
      start_time = time.time()
      while step < num_iter and not coord.should_stop():
        top_1, top_5 = sess.run([top_1_op, top_5_op])
        count_top_1 += np.sum(top_1)
        count_top_5 += np.sum(top_5)
        step += 1
        if step % 20 == 0:
          duration = time.time() - start_time
          sec_per_batch = duration / 20.0
          examples_per_sec = FLAGS.batch_size / sec_per_batch
          print('%s: [%d batches out of %d] (%.1f examples/sec; %.3f'
                'sec/batch)' % (datetime.now(), step, num_iter,
                                examples_per_sec, sec_per_batch))
          start_time = time.time()

      # Compute precision @ 1.
      precision_at_1 = count_top_1 / total_sample_count
      recall_at_5 = count_top_5 / total_sample_count
      print('%s: precision @ 1 = %.4f recall @ 5 = %.4f [%d examples]' %
            (datetime.now(), precision_at_1, recall_at_5, total_sample_count))

      summary = tf.Summary()
      summary.ParseFromString(sess.run(summary_op))
      summary.value.add(tag='Precision @ 1', simple_value=precision_at_1)
      summary.value.add(tag='Recall @ 5', simple_value=recall_at_5)
      summary_writer.add_summary(summary, global_step)

    except Exception as e:  # pylint: disable=broad-except
      coord.request_stop(e)

    coord.request_stop()
    coord.join(threads, stop_grace_period_secs=10)
1196027
private Object doNewInner(Object obj, boolean toLHS,
            CallStack callstack, Interpreter interpreter) throws EvalError {
        BSHAllocationExpression alloc = (BSHAllocationExpression) jjtGetChild(0);
        if (Reflect.isGeneratedClass(obj.getClass())) {
            callstack.pop();
            callstack.push(Reflect.getThisNS(obj));
            return alloc.eval(callstack, interpreter);
        }

        return alloc.constructFromEnclosingInstance(obj, callstack, interpreter);
    }
864488
def run(self, evals, feed_dict=None, breakpoints=None, break_immediately=False):
		
		if not isinstance(evals,list):
			evals=[evals]
		if feed_dict is None:
			feed_dict={}
		if breakpoints is None:
			breakpoints=[]

		self.state=RUNNING
		self._original_evals=evals
		self._original_feed_dict=feed_dict
		self._exe_order=op_store.compute_exe_order(evals)
		self._init_evals_bps(evals, breakpoints)

		# convert cache keys to strings
		for k,v in feed_dict.items():
			if not isinstance(k,str):
				k=k.name
			self._cache[k]=v

		op_store.register_dbsession(self)

		if break_immediately:
			return self._break()
		else:
			return self.c()
944797
protected Boolean doRun() throws Exception{
    Point<Object>	evals;
    Evaluation 		eval;
    Classifier 		classifier;
    Performance		performance;
    boolean		completed;

    // setup
    try {
      evals = m_Generator.evaluate(m_Values);
      classifier = (Classifier) m_Generator.setup((Serializable) m_Owner.getClassifier(), evals);
    }
    catch (Exception e) {
      m_Exception = e;
      System.err.println("Failed to configure classifier!");
      e.printStackTrace();
      return false;
    }

    // evaluate
    try {
      eval = new Evaluation(m_Train);
      eval.setDiscardPredictions(canDiscardPredictions());
      if (m_Test == null) {
        if (m_Folds >= 2) {
          eval.crossValidateModel(classifier, m_Train, m_Folds, new Random(m_Owner.getSeed()));
        }
        else {
          classifier.buildClassifier(m_Train);
          eval.evaluateModel(classifier, m_Train);
        }
      }
      else {
        classifier.buildClassifier(m_Train);
        eval.evaluateModel(classifier, m_Test);
      }
      completed = true;
    }
    catch (Exception e) {
      eval = null;
      m_Exception = e;
      System.err.println("Encountered exception while evaluating classifier, skipping!");
      System.err.println("- Classifier: " + m_Owner.getCommandline(classifier));
      e.printStackTrace();
      completed = false;
    }

    // store performance
    performance = new Performance(
      m_Values,
      m_Owner.getFactory().newWrapper(eval),
      m_Evaluation,
      m_ClassLabel,
      (Classifier) m_Generator.setup((Serializable) m_Owner.getClassifier(), evals));
    m_Owner.getAlgorithm().addPerformance(performance, m_Folds);

    // log
    m_Owner.log(performance + ": cached=false");

    return completed;
  }
913894
def run(self):
        

        stop_watcher = threading.Event()
        watcher = None
        if self.watch_func:
            watcher = threading.Thread(
                target=self.watch_func,
                args=(self.stack, stop_watcher)
            )
            watcher.start()

        try:
            while not self.done:
                self._run_once()
        finally:
            if watcher:
                stop_watcher.set()
                watcher.join()
        return self.ok
222557
def run_once(event)
      unless StripeWebhooks::PerformedCallback.exists?(stripe_event_id: event.id, label: label)
        run(event)
        StripeWebhooks::PerformedCallback.create(stripe_event_id: event.id, label: label)
      end
    end
713840
def run_once(function, state={}, errors={}):
    """"""
    @six.wraps(function)
    def _wrapper(*args, **kwargs):
        if function in errors:
            # Deliberate use of LBYL.
            six.reraise(*errors[function])

        try:
            return state[function]
        except KeyError:
            try:
                state[function] = result = function(*args, **kwargs)
                return result
            except Exception:
                errors[function] = sys.exc_info()
                raise
    return _wrapper
490816
function one(callback) {
        ///<summary>Execute a callback only once</summary>
        callback = callback || noop;

        if (callback._done) {
            return;
        }

        callback();
        callback._done = 1;
    }
934163
def flatten_once(iterable, check=is_iterable):
    """"""
    for value in iterable:
        if check(value):
            for item in value:
                yield item
        else:
            yield value
657375
def do_run_one(self, args):
        ''''''
        work_spec_names = args.from_work_spec or None
        worker = SingleWorker(self.config, task_master=self.task_master, work_spec_names=work_spec_names, max_jobs=args.max_jobs)
        worker.register()
        rc = False
        starttime = time.time()
        count = 0
        try:
            while True:
                rc = worker.run()
                if not rc:
                    break
                count += 1
                if (args.limit_seconds is None) and (args.limit_count is None):
                    # only do one
                    break
                if (args.limit_seconds is not None) and ((time.time() - starttime) >= args.limit_seconds):
                    break
                if (args.limit_count is not None) and (count >= args.limit_count):
                    break
        finally:
            worker.unregister()
        if not rc:
            self.exitcode = 2
659352
def _run_alg(self, max_iter):
        

        if self.progress:
            with ProgressBar(redirect_stdout=True, max_value=max_iter) as bar:
                self._iterations(max_iter, bar=bar)
        else:
            self._iterations(max_iter)
1170261
def _check_first_run(self):
        '''
        
        '''
        if self.cfg['first_run']:
            self.cfg['first_run'] = False
            self.cfg.save()
            return True
        else:
            return False
522842
private function repeatTagEndHandler(): void
    {
        $this->process_repeats--;
        if ($this->process_repeats > 0) {
            return;
        }

        // Check if there is anything to repeat
        if (count($this->repeats) > 0) {
            // No need to load them if not used...

            $lineoffset = 0;
            foreach ($this->repeats_stack as $rep) {
                $lineoffset += $rep[1];
            }
            //-- read the xml from the file
            $lines = file($this->report);
            while (strpos($lines[$lineoffset + $this->repeat_bytes], '<RepeatTag') === false) {
                $lineoffset--;
            }
            $lineoffset++;
            $reportxml = "<tempdoc>\n";
            $line_nr   = $lineoffset + $this->repeat_bytes;
            // RepeatTag Level counter
            $count = 1;
            while (0 < $count) {
                if (strstr($lines[$line_nr], '<RepeatTag') !== false) {
                    $count++;
                } elseif (strstr($lines[$line_nr], '</RepeatTag') !== false) {
                    $count--;
                }
                if (0 < $count) {
                    $reportxml .= $lines[$line_nr];
                }
                $line_nr++;
            }
            // No need to drag this
            unset($lines);
            $reportxml .= "</tempdoc>\n";
            // Save original values
            $this->parser_stack[] = $this->parser;
            $oldgedrec            = $this->gedrec;
            foreach ($this->repeats as $gedrec) {
                $this->gedrec  = $gedrec;
                $repeat_parser = xml_parser_create();
                $this->parser  = $repeat_parser;
                xml_parser_set_option($repeat_parser, XML_OPTION_CASE_FOLDING, false);

                xml_set_element_handler(
                    $repeat_parser,
                    function ($parser, string $name, array $attrs): void {
                        $this->startElement($parser, $name, $attrs);
                    },
                    function ($parser, string $name): void {
                        $this->endElement($parser, $name);
                    }
                );

                xml_set_character_data_handler(
                    $repeat_parser,
                    function ($parser, string $data): void {
                        $this->characterData($parser, $data);
                    }
                );

                if (!xml_parse($repeat_parser, $reportxml, true)) {
                    throw new DomainException(sprintf(
                        'RepeatTagEHandler XML error: %s at line %d',
                        xml_error_string(xml_get_error_code($repeat_parser)),
                        xml_get_current_line_number($repeat_parser)
                    ));
                }
                xml_parser_free($repeat_parser);
            }
            // Restore original values
            $this->gedrec = $oldgedrec;
            $this->parser = array_pop($this->parser_stack);
        }
        [$this->repeats, $this->repeat_bytes] = array_pop($this->repeats_stack);
    }
8836
def _eval(self, memory, addr, n, **kwargs):
        
        return memory.state.solver.eval_upto(addr, n, exact=kwargs.pop('exact', self._exact), **kwargs)
1353105
def eval_bool(self, expr):
        
        result = expr.eval(self)
        iterator = iter(result)
        try:
            next(iterator)
        except StopIteration:
            return False
        else:
            return True
        finally:
            if hasattr(iterator, "close"):
                iterator.close()
231719
public void startEval() throws IOException {
        startChangesIfNecessary();
        ResponseWriter writer = getWrapped();
        writer.startElement("eval", null);
        writer.startCDATA();
    }
992897
SaveReturn saveAnalysis(final File f) {

        Future<Object> waiter = mainFrame.getBackgroundExecutor().submit(() -> {
            BugSaver.saveBugs(f, mainFrame.getBugCollection(), mainFrame.getProject());
            return null;
        });
        try {
            waiter.get();
        } catch (InterruptedException e) {
            return SaveReturn.SAVE_ERROR;
        } catch (ExecutionException e) {
            return SaveReturn.SAVE_ERROR;
        }

        mainFrame.setProjectChanged(false);

        return SaveReturn.SAVE_SUCCESSFUL;
    }