def sendBacklogDataToModel(conn, metricId, logger):
  """ Send backlog data to OPF/CLA model. Do not call this before starting the
  model.

  :param conn: SQLAlchemy Connection object for executing SQL
  :type conn: sqlalchemy.engine.Connection

  :param metricId: unique identifier of the metric row

  :param logger: logger object

  """
  backlogData = tuple(
    model_swapper_interface.ModelInputRow(
      rowID=md.rowid, data=(md.timestamp, md.metric_value,))
    for md in repository.getMetricData(
                conn,
                metricId,
                fields=[schema.metric_data.c.rowid,
                        schema.metric_data.c.timestamp,
                        schema.metric_data.c.metric_value]))

  if backlogData:
    with model_swapper_interface.ModelSwapperInterface() as modelSwapper:
      model_data_feeder.sendInputRowsToModel(
        modelId=metricId,
        inputRows=backlogData,
        batchSize=config.getint("metric_streamer", "chunk_size"),
        modelSwapper=modelSwapper,
        logger=logger,
        profiling=(config.getboolean("debugging", "profiling") or
                   logger.isEnabledFor(logging.DEBUG)))

  logger.info("sendBacklogDataToModel: sent %d backlog data rows to model=%s",
              len(backlogData), metricId)
def sendBacklogDataToModel(conn, metricId, logger):
  """ Send backlog data to OPF/CLA model. Do not call this before starting the
  model.

  :param conn: SQLAlchemy Connection object for executing SQL
  :type conn: sqlalchemy.engine.Connection

  :param metricId: unique identifier of the metric row

  :param logger: logger object

  """
  backlogData = tuple(
    model_swapper_interface.ModelInputRow(
      rowID=md.rowid, data=(md.timestamp, md.metric_value,))
    for md in repository.getMetricData(
      conn,
      metricId,
      fields=[schema.metric_data.c.rowid,
              schema.metric_data.c.timestamp,
              schema.metric_data.c.metric_value]))

  if backlogData:
    with model_swapper_interface.ModelSwapperInterface() as modelSwapper:
      model_data_feeder.sendInputRowsToModel(
        modelId=metricId,
        inputRows=backlogData,
        batchSize=config.getint("metric_streamer", "chunk_size"),
        modelSwapper=modelSwapper,
        logger=logger,
        profiling=(config.getboolean("debugging", "profiling") or
                   logger.isEnabledFor(logging.DEBUG)))

  logger.info("sendBacklogDataToModel: sent %d backlog data rows to model=%s",
              len(backlogData), metricId)
Exemplo n.º 3
0
    def _sendInputRowsToModel(self, inputRows, metricID, modelSwapper):
        """ Send input rows to CLA model for processing

    :param inputRows: sequence of model_swapper_interface.ModelInputRow objects
    """
        model_data_feeder.sendInputRowsToModel(
            modelId=metricID,
            inputRows=inputRows,
            batchSize=self._metricDataOutputChunkSize,
            modelSwapper=modelSwapper,
            logger=self._log,
            profiling=self._profiling)
  def _sendInputRowsToModel(self, inputRows, metricID, modelSwapper):
    """ Send input rows to CLA model for processing

    :param inputRows: sequence of model_swapper_interface.ModelInputRow objects
    """
    model_data_feeder.sendInputRowsToModel(
      modelId=metricID,
      inputRows=inputRows,
      batchSize=self._metricDataOutputChunkSize,
      modelSwapper=modelSwapper,
      logger=self._log,
      profiling=self._profiling)