method computes new unit_of_work and transfers the job to STATE_FINAL_RUN
        it also shares _fuzzy_ DuplicateKeyError logic from _compute_and_transfer_to_progress method
430554
def _compute_and_transfer_to_final_run(self, process_name, start_timeperiod, end_timeperiod, job_record):
        
        source_collection_name = context.process_context[process_name].source
        start_id = self.ds.highest_primary_key(source_collection_name, start_timeperiod, end_timeperiod)
        end_id = self.ds.lowest_primary_key(source_collection_name, start_timeperiod, end_timeperiod)
        uow, transfer_to_final = self.insert_and_publish_uow(job_record, start_id, end_id)
        self.update_job(job_record, uow, job.STATE_FINAL_RUN)

        if transfer_to_final:
            self._process_state_final_run(job_record)
456606
private double computeFinalWeight(final int outputStateId,
                                    final DetStateTuple targetTuple,
                                    Deque<DetElement> finalQueue) {
    UnionWeight<GallicWeight> result = this.unionSemiring.zero();
    for (DetElement detElement : targetTuple.getElements()) {
      State inputState = this.getInputStateForId(detElement.inputStateId);
      if (this.semiring.isZero(inputState.getFinalWeight())) {
        continue; // not final so it wont contribute
      }
      UnionWeight<GallicWeight> origFinal = UnionWeight.createSingle(GallicWeight.createEmptyLabels(
        inputState.getFinalWeight()));
      result = this.unionSemiring.plus(result, this.unionSemiring.times(detElement.residual, origFinal));
    }
    if (this.unionSemiring.isZero(result)) {
      return this.semiring.zero();
    }
    if (result.size() == 1 && result.get(0).getLabels().isEmpty()) {
      // by good fortune the residual is just a weight, no path to expand so this new state can have a final weight
      // set now! with nothing to enqueue
      return result.get(0).getWeight();
    }
    // this state can't be a final state because we have more path to emit so defer until later; we know that we cant
    // have any duplicate elements in the finalQueue since we only call computeFinalWeight once for each outputStateId
    finalQueue.addLast(new DetElement(outputStateId, result));
    return this.semiring.zero(); // since we're deferring this weight can't be a final weight
  }
782484
def check_for_completion
      return unless all_work_units_complete?
      set_next_status
      outs = gather_outputs_from_work_units
      return queue_for_workers([outs]) if merging?
      if complete?
        update_attributes(:outputs => outs, :time => time_taken)
        CloudCrowd.log "Job ##{id} (#{action}) #{display_status}." unless ENV['RACK_ENV'] == 'test'
        CloudCrowd.defer { fire_callback } if callback_url
      end
      self
    end
475234
def _finalize_outputs(cls, mapreduce_spec, mapreduce_state):
    
    # Only finalize the output writers if the job is successful.
    if (mapreduce_spec.mapper.output_writer_class() and
        mapreduce_state.result_status == model.MapreduceState.RESULT_SUCCESS):
      mapreduce_spec.mapper.output_writer_class().finalize_job(mapreduce_state)
586159
public void compute2() {
      try {
        Scope.enter();
        _parms.read_lock_frames(_job); // Fetch & read-lock input frames
        computeImpl();
        saveModelCheckpointIfConfigured();
      } finally {
        setFinalState();
        _parms.read_unlock_frames(_job);
        if (!_parms._is_cv_model) cleanUp(); //cv calls cleanUp on its own terms
        Scope.exit();
      }
      tryComplete();
    }
1370697
def _create_in_progress(self):
        
        instance = self.service.service.get_instance(self.service.name)
        if (instance['last_operation']['state'] == 'in progress' and
           instance['last_operation']['type'] == 'create'):
               return True

        return False
902629
def commit(self, unit_of_work):
        
        MemoryRepository.commit(self, unit_of_work)
        if self.is_initialized:
            entity_classes_to_dump = set()
            for state in unit_of_work.iterator():
                entity_classes_to_dump.add(type(state.entity))
            for entity_cls in entity_classes_to_dump:
                self.__dump_entities(entity_cls)
585912
def process(job = nil, &block)
      return unless job ||= reserve

      job.worker = self
      working_on job
      perform(job, &block)
    ensure
      done_working
    end
616044
private   final void dcompute() {// Work to do the distribution
    // Split out the keys into disjointly-homed sets of keys.
    // Find the split point.  First find the range of home-indices.
    H2O cloud = H2O.CLOUD;
    int lo=cloud._memary.length, hi=-1;
    for( Key k : _keys ) {
      int i = k.home(cloud);
      if( i<lo ) lo=i;
      if( i>hi ) hi=i;        // lo <= home(keys) <= hi
    }

    // Classic fork/join, but on CPUs.
    // Split into 3 arrays of keys: lo keys, hi keys and self keys
    final ArrayList<Key> locals = new ArrayList<Key>();
    final ArrayList<Key> lokeys = new ArrayList<Key>();
    final ArrayList<Key> hikeys = new ArrayList<Key>();
    int self_idx = cloud.nidx(H2O.SELF);
    int mid = (lo+hi)>>>1;    // Mid-point
    for( Key k : _keys ) {
      int idx = k.home(cloud);
      if( idx == self_idx ) locals.add(k);
      else if( idx < mid )  lokeys.add(k);
      else                  hikeys.add(k);
    }

    // Launch off 2 tasks for the other sets of keys, and get a place-holder
    // for results to block on.
    _lo = remote_compute(lokeys);
    _hi = remote_compute(hikeys);

    // Setup for local recursion: just use the local keys.
    if( locals.size() != 0 ) {  // Shortcut for no local work
      _local = clone();         // 'this' is completer for '_local', so awaits _local completion
      _local._is_local = true;
      _local._keys = locals.toArray(new Key[locals.size()]); // Keys, including local keys (if any)
      _local.init();            // One-time top-level init
      H2O.submitTask(_local);   // Begin normal execution on a FJ thread
    } else {
      tryComplete();            // No local work, so just immediate tryComplete
    }
  }
1319606
function resolve() {
      var deferred = this,
          clone = deferred.benchmark,
          bench = clone._original;

      if (bench.aborted) {
        // cycle() -> clone cycle/complete event -> compute()'s invoked bench.run() cycle/complete.
        deferred.teardown();
        clone.running = false;
        cycle(deferred);
      }
      else if (++deferred.cycles < clone.count) {
        clone.compiled.call(deferred, context, timer);
      }
      else {
        timer.stop(deferred);
        deferred.teardown();
        delay(clone, function() { cycle(deferred); });
      }
    }
1132200
def finished(self):
    

    return self.__state in (Job.ERROR, Job.SUCCESS, Job.CANCELLED)
984512
def update_job(self, job_record, uow, new_state):
        
        original_job_state = job_record.state
        job_record.state = new_state
        job_record.related_unit_of_work = uow.db_id
        self.job_dao.update(job_record)

        msg = 'Updated Job {0} for {1}@{2}: state transfer {3} -> {4};' \
              .format(job_record.db_id, job_record.process_name, job_record.timeperiod, original_job_state, new_state)
        self._log_message(INFO, job_record.process_name, job_record.timeperiod, msg)
516536
function completeJob(loader, job, callback) {
    var nextJob;

    loader.jobsInProgress--;

    if ((!loader.jobLimit || loader.jobsInProgress < loader.jobLimit) && loader.jobQueue.length > 0) {
        nextJob = loader.jobQueue.shift();
        nextJob.start();
        loader.jobsInProgress++;
    }

    callback(job.image, job.errorMsg, job.request);
}
62864
private void makeJobRunning(JobInProgress job, JobSchedulingInfo oldInfo, 
                              QueueInfo qi) {
    // Removing of the job from job list is responsibility of the
    //initialization poller.
    // Add the job to the running queue
    qi.addRunningJob(job);
  }
402714
def add_final_state(self, f):

        
        if f not in self.Q:
            LOG.error("The specified value is invalid, f must be a member of Q")
            raise InputError("The specified value is invalid, f must be a member of Q")

        self.F.add(f)
968946
def process_push
      factory = "::#{object_type}".constantize
      local_object = factory.find(object_local_id)
      syncer = factory.synchronizer
      syncer.push_object(local_object)
      
      self.state = 'done'
      self.save
    end
56088
def step_worker(step, pipe, max_entities):
    
    state = None
    while True:
        message, input = pipe.recv()
        if message == 'run':
            state = step.run(input, max_entities)
        elif message == 'finalise':
            state = step.finalise(max_entities)
        elif message == 'next':
            try:
                data = state.next()
                sys.stderr.write('  {}\n'.format(step.name))
                sys.stderr.write('  * {}\n'.format(', '.join(key.name for key in data)))
                sys.stderr.write('  *  {}\n'.format(', '.join(str(value) for value in data.values())))
                pipe.send(('data', {'step': step, 'data': data}))
            except StopIteration:
                pipe.send(('stop', {'step': step}))
                state = None
        elif message == 'stop':
            break