Submit a populator batch

        Submit a populator batch as a series of HTTP requests in small chunks,
        returning the batch GUID, or raising exception on error.
353517
def submit_populator_batch(self, column_name, batch):
        """"""
        if not set(column_name).issubset(_allowedCustomDimensionChars):
            raise ValueError('Invalid custom dimension name "%s": must only contain letters, digits, and underscores' % column_name)
        if len(column_name) < 3 or len(column_name) > 20:
            raise ValueError('Invalid value "%s": must be between 3-20 characters' % column_name)

        url = '%s/api/v5/batch/customdimensions/%s/populators' % (self.base_url, column_name)
        resp_json_dict = self._submit_batch(url, batch)
        if resp_json_dict.get('error') is not None:
            raise RuntimeError('Error received from server: %s' % resp_json_dict['error'])

        return resp_json_dict['guid']
1090807
def batch_generate_pdfs(submission_batch_data, opts = {})
      data, _status_code, _headers = batch_generate_pdfs_with_http_info(submission_batch_data, opts)
      data
    end
760923
def create_document_batches(jsonlines, id_field, max_batch_size=CLOUDSEARCH_MAX_BATCH_SIZE):
    
    batch = []
    fixed_initial_size = 2

    def create_entry(line):
        try:
            record = json.loads(line)
        except:
            raise ValueError('Could not parse JSON from: %s' % line)
        key = record[id_field]
        return '{"type":"add","id":%s,"fields":%s}' % (json.dumps(key), line)

    current_size = fixed_initial_size
    for line in jsonlines:
        entry = create_entry(line)
        entry_size = len(entry) + 1

        if max_batch_size > (current_size + entry_size):
            current_size += entry_size
            batch.append(entry)
        else:
            yield '[' + ','.join(batch) + ']'
            batch = [entry]
            current_size = fixed_initial_size + entry_size

    if batch:
        yield '[' + ','.join(batch) + ']'
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);
      }
    });
  }
}
48345
def batch(request, request_options = {})
      client.post(Protocol.batch_uri(name), request.to_json, :batch, request_options)
    end
450647
def _process_bulk_chunk(self, bulk_actions, raise_on_exception=True, raise_on_error=True, **kwargs):
        
        # if raise on error is set, we need to collect errors per chunk before
        # raising them

        resp = None
        try:
            # send the actual request
            actions = "{}\n".format('\n'.join(bulk_actions))
            resp = yield self.client.bulk(actions, **kwargs)
        except ConnectionTimeout as e:
            # default behavior - just propagate exception
            if raise_on_exception:
                raise

            self._handle_transport_error(bulk_actions, e, raise_on_error)
            returnValue([])

        # go through request-response pairs and detect failures
        errors = []
        results = []
        for op_type, item in map(methodcaller('popitem'), resp['items']):
            ok = 200 <= item.get('status', 500) < 300
            if not ok and raise_on_error:
                errors.append({op_type: item})

            if ok or not errors:
                # if we are not just recording all errors to be able to raise
                # them all at once, yield items individually
                results.append((ok, {op_type: item}))

        if errors:
            msg_fmt = '{num} document(s) failed to index.'
            raise BulkIndexError(msg_fmt.format(num=len(errors)), errors)
        else:
            returnValue(results)
1342432
def collect_api_results(input_data, url, headers, api, batch_size, kwargs):
    
    if batch_size:
        results = []
        for batch in batched(input_data, size=batch_size):
            try:
                result = send_request(batch, api, url, headers, kwargs)
                if isinstance(result, list):
                    results.extend(result)
                else:
                    results.append(result)
            except IndicoError as e:
                # Log results so far to file
                timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
                filename = "indico-{api}-{timestamp}.json".format(
                    api=api,
                    timestamp=timestamp
                )
                if sys.version_info > (3, 0):
                    json.dump(results, open(filename, mode='w', encoding='utf-8'), cls=NumpyEncoder)
                else:
                    json.dump(results, open(filename, mode='w'), cls=NumpyEncoder)
                raise BatchProcessingError(
                    "The following error occurred while processing your data: `{err}` "
                    "Partial results have been saved to {filename}".format(
                        err=e,
                        filename=os.path.abspath(filename)
                    )
                )
        return results
    else:
        return send_request(input_data, api, url, headers, kwargs)
1183700
def submit(self, call, *args, **kwargs):
        
        future = StoredFuture(call, *args, **kwargs)
        self._queue.put(future)
        self._ensure_worker()
        return future
811009
public Future<WriteResponse> write (Batch<String> batch, WriteCallback callback) {
    Timer.Context context = writeTimer.time();
    int returnCode = 0;
    LOG.info ("Dispatching batch " + batch.getId());
    recordsAttempted.mark(batch.getRecords().size());
    try {
      String encoded = encodeBatch(batch);
      returnCode = request (encoded);
      WriteResponse<Integer> response = WRITE_RESPONSE_WRAPPER.wrap(returnCode);
      callback.onSuccess(response);
      bytesWritten.mark(encoded.length());
      recordsSuccess.mark(batch.getRecords().size());
    } catch (Exception e) {
      LOG.error("Dispatching batch " + batch.getId() + " failed :" + e.toString());
      callback.onFailure(e);
      recordsFailed.mark(batch.getRecords().size());
    }

    context.close();
    Future<Integer> future = Futures.immediateFuture(returnCode);
    return new WriteResponseFuture<>(future, WRITE_RESPONSE_WRAPPER);
  }
733014
public function executeBatch($batchUid)
    {
        $endpoint = vsprintf('batches/%s', [$batchUid]);
        $requestData = $this->getDefaultRequestData('json', [
          'action' => self::ACTION_EXECUTE,
        ]);

        return $this->sendRequest($endpoint, $requestData, self::HTTP_METHOD_POST);
    }
656922
public void executeBatch(BatchOperation batchOperation) throws FMSException {

        IntuitMessage intuitMessage = prepareBatch(batchOperation);

        //execute interceptors
        executeInterceptors(intuitMessage);

        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            List<BatchItemResponse> batchItemResponses = intuitResponse.getBatchItemResponse();
            if (batchItemResponses != null && !batchItemResponses.isEmpty()) {
                int count = 0;
                Iterator<BatchItemResponse> itr = batchItemResponses.iterator();
                while (itr.hasNext()) {
                    BatchItemResponse batchItemResponse = itr.next();
                    String bId = batchItemResponse.getBId();
                    if (!StringUtils.hasText(bId)) {
                        bId = batchOperation.getBatchItemRequests().get(count).getBId();
                    }
                    if (batchItemResponse.getFault() != null) {
                        // segregate fault batch items
                        batchOperation.getFaultResult().put(bId, batchItemResponse.getFault());
                    } else if (batchItemResponse.getReport() != null) {
                        // segregate report batch items
                        batchOperation.getReportResult().put(bId, batchItemResponse.getReport());
                    } else if (batchItemResponse.getIntuitObject() != null) {
                        // segregate entity batch items
                        batchOperation.getEntityResult().put(bId, (IEntity) batchItemResponse.getIntuitObject().getValue());
                    } else if (batchItemResponse.getQueryResponse() != null) {
                        // segregate query batch items
                        QueryResult queryResult = getQueryResult(batchItemResponse.getQueryResponse());
                        batchOperation.getQueryResult().put(bId, queryResult);
                    } else if (batchItemResponse.getCDCResponse() != null) {
                        // segregate cdc query batch items
                        CDCQueryResult cdcQueryResult = getCDCQueryResult(batchItemResponse.getCDCResponse());
                        batchOperation.getCDCQueryResult().put(bId, cdcQueryResult);
                    } else {
                        LOG.warn("BatchItemResponse is not Fault, Entity, Query and Report.");
                    }
                    count++;
                }
            }
        }
    }
563621
function batchCmd(cmdArray, callback){

        var requestJson = [];

        for (var i = 0; i < cmdArray.length; i++){
            requestJson.push({
                method: cmdArray[i][0],
                params: cmdArray[i][1],
                id: Date.now() + Math.floor(Math.random() * 10) + i
            });
        }

        var serializedRequest = JSON.stringify(requestJson);

        performHttpRequest(instances[0], serializedRequest, function(error, result){
            callback(error, result);
        });

    }
729298
public void batchCommitted()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "batchCommitted");
      
    if (batchSendList.size() != 0)
    {
      try
      {
        sendMsgs(batchSendList, false);
      }
      catch (SIResourceException e)
      {
        //FFDC
        FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.gd.SourceStream.batchCommitted",
          "1:2590:1.138",
          this);

        SibTr.exception(tc, e);
      }
    }
    
    // Empty list ready for use by next batch
    batchList.clear();
    batchSendList.clear();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "batchCommitted");
  }
1040629
def insert_request_to_batch(self, request):
        '''
        
        '''
        self.validate_request_table(request)
        self.validate_request_partition_key(request)
        self.validate_request_row_key(request)
        self.batch_requests.append(request)
10421
def submit(self, value):
    """"""
    # Add a batch dimension if necessary.
    if value.shape.ndims == self._sum.shape.ndims:
      value = value[None, ...]
    return tf.group(
        self._sum.assign_add(tf.reduce_sum(value, 0)),
        self._count.assign_add(tf.shape(value)[0]))
989072
def get_submission_batch(submission_batch_id, opts = {})
      data, _status_code, _headers = get_submission_batch_with_http_info(submission_batch_id, opts)
      data
    end
791973
def update_batches() -> None:
    ""
    batches_data  = requests.get(BATCHES_API_URL).json()
    batches_url   = {i["name"]: i["download_url"] for i in batches_data
                     if i["type"] == "file"}
    order_batches = sorted(batches_url, key=int)

    try:
        existing = set(os.listdir(BATCHES_DIR))
    except FileNotFoundError:
        BATCHES_DIR.mkdir(parents=True)
        existing = set()

    def get_batch(name: str) -> None:
        if name in existing and name != order_batches[-1]:
            return

        answer = requests.get(batches_url[name])
        try:
            answer.raise_for_status()
        except requests.RequestException:
            return

        with AtomicFile(BATCHES_DIR / name, "w") as file:
            file.write(answer.text)

    ThreadPool(8).map(get_batch, order_batches)