Action for checking all assigned rounds using a batch
486264
public function recalcAllFieldsAction()
    {
        $respondent = $this->getRespondent();
        $where      = $this->db->quoteInto('gr2t_id_user = ?', $respondent->getId());

        $batch = $this->loader->getTracker()->recalcTrackFields(
                'trackRecalcFieldsResp_' . $respondent->getId(),
                $where
                );

        $title = sprintf(
                $this->_('Recalculating fields for all tracks of respondent %s, %s.'),
                $respondent->getPatientNumber(),
                $respondent->getFullName()
                );
        $this->_helper->BatchRunner($batch, $title, $this->accesslog);

        $this->addSnippet('Track\\RecalcFieldsInformation');
    }
924684
def workflow_validate_batch(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/validateBatch' % object_id, input_params, always_retry=always_retry, **kwargs)
25294
def on_batch_begin(self, last_input, last_target, **kwargs):
        ""
        if self.clip is not None:
            for p in self.critic.parameters(): p.data.clamp_(-self.clip, self.clip)
        return {'last_input':last_input,'last_target':last_target} if self.gen_mode else {'last_input':last_target,'last_target':last_input}
598029
def execute_batch
    check_closed

    cnt = 0

    if @bstmt
      cnt += @bstmt.execute_batch.inject(:+) || 0
      @spool.give @bstmt
      @bstmt = nil
    end

    @pstmts.each do |pstmt|
      cnt += pstmt.execute_batch
    end

    cnt
  end
455052
function executeBatches(bulkOperation, options, callback) {
  let numberOfCommandsToExecute = bulkOperation.s.batches.length;
  // Execute over all the batches
  for (let i = 0; i < bulkOperation.s.batches.length; i++) {
    executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
      // Count down the number of commands left to execute
      numberOfCommandsToExecute = numberOfCommandsToExecute - 1;

      // Execute
      if (numberOfCommandsToExecute === 0) {
        // Driver level error
        if (err) return handleCallback(callback, err);

        const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
        if (bulkOperation.handleWriteError(callback, writeResult)) return;

        return handleCallback(callback, null, writeResult);
      }
    });
  }
}
463568
public void batch(List<? extends Row> actions, @Nullable Object[] results)
      throws IOException, InterruptedException {
    if (results == null) {
      results = new Object[actions.size()];
    }
    batchCallback(actions, results, null);
  }
1287288
def _check_for_batch_clashes(xs):
    
    names = set([x["description"] for x in xs])
    dups = set([])
    for x in xs:
        batches = tz.get_in(("metadata", "batch"), x)
        if batches:
            if not isinstance(batches, (list, tuple)):
                batches = [batches]
            for batch in batches:
                if batch in names:
                    dups.add(batch)
    if len(dups) > 0:
        raise ValueError("Batch names must be unique from sample descriptions.\n"
                         "Clashing batch names: %s" % sorted(list(dups)))
724179
function batch( target, method, options ) {
    var i, len;

    // Selector
    if( typeof target === 'string' ) {
      var targets = document.querySelectorAll( target );

      for( i = 0, len = targets.length; i < len; i++ ) {
        method.call( null, targets[i], options );
      }
    }
    // Array (jQuery)
    else if( typeof target === 'object' && typeof target.length === 'number' ) {
      for( i = 0, len = target.length; i < len; i++ ) {
        method.call( null, target[i], options );
      }
    }
    // Single element
    else if( target.nodeName ) {
      method.call( null, target, options );
    }
    else {
      throw 'Stroll target was of unexpected type.';
    }
  }
797867
public function execute($lineNr = null, $roundData = null)
    {
        $batch  = $this->getBatch();
        $events = $this->loader->getEvents();
        $import = $batch->getVariable('import');

        if (isset($roundData['gro_id_order']) && $roundData['gro_id_order']) {
            $import['roundOrder'][$roundData['gro_id_order']] = false;
        } else {
            $batch->addToCounter('import_errors');
            $batch->addMessage(sprintf(
                $this->_('No gro_id_order specified for round at line %d.'),
                $lineNr
                ));
        }
        if (isset($roundData['survey_export_code']) && $roundData['survey_export_code']) {
            if (! (isset($import['surveyCodes']) &&
                    array_key_exists($roundData['survey_export_code'], $import['surveyCodes']))) {
                $batch->addToCounter('import_errors');
                $batch->addMessage(sprintf(
                        $this->_('Unknown survey export code "%s" specified for round on line %d.'),
                        $roundData['survey_export_code'],
                        $lineNr
                        ));
            }
        } else {
            $batch->addToCounter('import_errors');
            $batch->addMessage(sprintf(
                    $this->_('No survey export code specified for round on line %d.'),
                    $lineNr
                    ));
        }
        if (isset($roundData['gro_changed_event']) && $roundData['gro_changed_event']) {
            try {
                $events->loadRoundChangedEvent($roundData['gro_changed_event']);
            } catch (\Gems_Exception_Coding $ex) {
                $batch->addToCounter('import_errors');
                $batch->addMessage(sprintf(
                        $this->_('Unknown or invalid round changed event "%s" specified on line %d.'),
                        $roundData['gro_changed_event'],
                        $lineNr
                        ));
            }
        }
        if (isset($roundData['gro_display_event']) && $roundData['gro_display_event']) {
            try {
                $events->loadSurveyDisplayEvent($roundData['gro_display_event']);
            } catch (\Gems_Exception_Coding $ex) {
                $batch->addToCounter('import_errors');
                $batch->addMessage(sprintf(
                        $this->_('Unknown or invalid round display event "%s" specified on line %d.'),
                        $roundData['gro_display_event'],
                        $lineNr
                        ));
            }
        }
    }
648955
def current_batch
      start_position = output[:planned_count]
      size = start_position + batch_size > total_count ? total_count - start_position : batch_size
      batch(start_position, size)
    end
1343931
def perform_action(
            self, action, machines, params, progress_title, success_title):
        """"""
        if len(machines) == 0:
            return 0
        with utils.Spinner() as context:
            return self._async_perform_action(
                context, action, list(machines), params,
                progress_title, success_title)
476584
def filter_batch(self, batch):
        
        for item in batch:
            if self.filter(item):
                yield item
            else:
                self.set_metadata('filtered_out',
                                  self.get_metadata('filtered_out') + 1)

            self.total += 1
            self._log_progress()
1021426
def check(self, batch_size):
        """"""
        self.increment(batch_size)
        return self.unit_count >= self.config["log_train_every"]
1285222
public function checkAction()
    {
        $surveyId = $this->getSurveyId();
        $where    = $this->db->quoteInto('gto_id_survey = ?', $surveyId);

        $batch = $this->loader->getTracker()->recalculateTokens('surveyCheck' . $surveyId, $this->currentUser->getUserId(), $where);

        $title = sprintf($this->_('Checking for the %s survey for answers .'),
                $this->db->fetchOne("SELECT gsu_survey_name FROM gems__surveys WHERE gsu_id_survey = ?", $surveyId));
        $this->_helper->BatchRunner($batch, $title, $this->accesslog);

        $this->addSnippet('Survey\\CheckAnswersInformation',
                'itemDescription', $this->_('This task checks all tokens using this survey for answers.')
                );
    }
1053712
def process_batches(self):
        
        for key, batch in iteritems(self._batches):
            self._current_tups = batch
            self._current_key = key
            self.process_batch(key, batch)
            if self.auto_ack:
                for tup in batch:
                    self.ack(tup)
            # Set current batch to [] so that we know it was acked if a
            # later batch raises an exception
            self._current_key = None
            self._batches[key] = []
        self._batches = defaultdict(list)
1312918
def write_batch(self, batch):
        
        for item in batch:
            self.write_buffer.buffer(item)
            key = self.write_buffer.get_key_from_item(item)
            if self.write_buffer.should_write_buffer(key):
                self._write_current_buffer_for_group_key(key)
            self.increment_written_items()
            self._check_items_limit()
296512
def on_batch_end(self, last_output, last_target, **kwargs):
        ""
        if not is_listy(last_target): last_target=[last_target]
        self.count += last_target[0].size(0)
        val = self.func(last_output, *last_target)
        if self.world:
            val = val.clone()
            dist.all_reduce(val, op=dist.ReduceOp.SUM)
            val /= self.world
        self.val += last_target[0].size(0) * val.detach().cpu()