コード例 #1
0
ファイル: __init__.py プロジェクト: sergius/numenta-apps
    def activateModel(self, metricId):
        """ Start a model that is PENDING_DATA, creating the OPF/CLA model

    NOTE: used by MetricStreamer when model is in PENDING_DATA state and
      sufficient data samples are available to get statistics and complete model
      creation.

    :param metricId: unique identifier of the metric row

    :raises grok.app.exceptions.ObjectNotFoundError: if metric with the
      referenced metric uid doesn't exist

    :raises grok.app.exceptions.MetricStatisticsNotReadyError:
    """
        with self.connectionFactory() as conn:
            # TODO: This function is identical to custom metric activateModel()
            metricObj = repository.getMetric(
                conn, metricId, fields=[schema.metric.c.datasource, schema.metric.c.parameters]
            )

        if metricObj.datasource != self._DATASOURCE:
            raise TypeError("activateModel: not a cloudwatch metric=%r" % (metricObj,))

        if metricObj.parameters:
            parameters = htmengine.utils.jsonDecode(metricObj.parameters)
        else:
            parameters = {}

        stats = self._getMetricStatistics(parameters["metricSpec"])

        self._log.info("activateModel: metric=%s, stats=%r", metricId, stats)

        swarmParams = scalar_metric_utils.generateSwarmParams(stats)

        scalar_metric_utils.startModel(metricId, swarmParams=swarmParams, logger=self._log)
コード例 #2
0
ファイル: __init__.py プロジェクト: AmitShah/numenta-apps
  def activateModel(self, metricId):
    """ Start a model that is PENDING_DATA, creating the OPF/CLA model

    NOTE: used by MetricStreamer when model is in PENDING_DATA state and
      sufficient data samples are available to get statistics and complete model
      creation.

    :param metricId: unique identifier of the metric row

    :raises htmengine.exceptions.ObjectNotFoundError: if metric with the
      referenced metric uid doesn't exist

    :raises htmengine.exceptions.MetricStatisticsNotReadyError:
    """
    # Load the existing metric
    with self.connectionFactory() as conn:
      metricObj = repository.getMetric(conn,
                                       metricId,
                                       fields=[schema.metric.c.datasource])

    if metricObj.datasource != self._DATASOURCE:
      raise TypeError(
        "activateModel: not an HTM metric=%s; datasource=%s" %
        (metricId, metricObj.datasource))

    stats = self._getMetricStatistics(metricId)

    swarmParams = scalar_metric_utils.generateSwarmParams(stats)

    scalar_metric_utils.startModel(metricId,
                                   swarmParams=swarmParams,
                                   logger=self._log)
コード例 #3
0
    def activateModel(self, metricId):
        """ Start a model that is PENDING_DATA, creating the OPF/CLA model

    NOTE: used by MetricStreamer when model is in PENDING_DATA state and
      sufficient data samples are available to get statistics and complete model
      creation.

    :param metricId: unique identifier of the metric row

    :raises htmengine.exceptions.ObjectNotFoundError: if metric with the
      referenced metric uid doesn't exist

    :raises htmengine.exceptions.MetricStatisticsNotReadyError:
    """
        # Load the existing metric
        with self.connectionFactory() as conn:
            metricObj = repository.getMetric(
                conn, metricId, fields=[schema.metric.c.datasource])

        if metricObj.datasource != self._DATASOURCE:
            raise TypeError(
                "activateModel: not an HTM metric=%s; datasource=%s" %
                (metricId, metricObj.datasource))

        stats = self._getMetricStatistics(metricId)

        swarmParams = scalar_metric_utils.generateSwarmParams(stats)

        scalar_metric_utils.startModel(metricId,
                                       swarmParams=swarmParams,
                                       logger=self._log)
コード例 #4
0
    def activateModel(self, metricId):
        """ Start a model that is PENDING_DATA, creating the OPF/CLA model

    NOTE: used by MetricStreamer when model is in PENDING_DATA state and
      sufficient data samples are available to get statistics and complete model
      creation.

    :param metricId: unique identifier of the metric row

    :raises htm.it.app.exceptions.ObjectNotFoundError: if metric with the
      referenced metric uid doesn't exist

    :raises htm.it.app.exceptions.MetricStatisticsNotReadyError:
    """
        with self.connectionFactory() as conn:
            # TODO: This function is identical to custom metric activateModel()
            metricObj = repository.getMetric(conn,
                                             metricId,
                                             fields=[
                                                 schema.metric.c.datasource,
                                                 schema.metric.c.parameters
                                             ])

        if metricObj.datasource != self._DATASOURCE:
            raise TypeError("activateModel: not a cloudwatch metric=%r" %
                            (metricObj, ))

        if metricObj.parameters:
            parameters = htmengine.utils.jsonDecode(metricObj.parameters)
        else:
            parameters = {}

        stats = self._getMetricStatistics(parameters["metricSpec"])

        self._log.info("activateModel: metric=%s, stats=%r", metricId, stats)

        swarmParams = scalar_metric_utils.generateSwarmParams(stats)

        scalar_metric_utils.startModel(metricId,
                                       swarmParams=swarmParams,
                                       logger=self._log)