Пример #1
0
    def parse_file(self, directory):
        mls = []
        for f in self.parser.find_all_files(directory):
            if os.path.isdir(f):
                continue
            try:
                self.logger.info(f + " will be parsed.")
                mls.extend(self.parser.parse_summary(f, self.metrics))
            except Exception as e:
                self.logger.warning("Unexpected error: " + str(e))
                continue

        # Metrics logs must contain at least one objective metric value
        # Objective metric is located at first index
        is_objective_metric_reported = False
        for ml in mls:
            if ml.metric.name == self.metrics[0]:
                is_objective_metric_reported = True
                break
        # If objective metrics were not reported, insert unavailable value in the DB
        if not is_objective_metric_reported:
            mls = [
                api_pb2.MetricLog(time_stamp=rfc3339.rfc3339(datetime.now()),
                                  metric=api_pb2.Metric(
                                      name=self.metrics[0],
                                      value=const.UNAVAILABLE_METRIC_VALUE))
            ]
            self.logger.info(
                "Objective metric {} is not found in training logs, {} value is reported"
                .format(self.metrics[0], const.UNAVAILABLE_METRIC_VALUE))

        return api_pb2.ObservationLog(metric_logs=mls)
Пример #2
0
 def parse_file(self, directory):
     mls = []
     for f in self.parser.find_all_files(directory):
         if os.path.isdir(f):
             continue
         try:
             self.logger.info(f + " will be parsed.")
             mls = self.parser.parse_summary(f, self.metrics)
         except Exception as e:
             self.logger.warning("Unexpected error: " + str(e))
             continue
     return api_pb2.ObservationLog(metric_logs=mls)
Пример #3
0
class MetricsCollector:
    def __init__(self, metric_names):
        self.logger = getLogger(__name__)
        handler = StreamHandler()
        handler.setLevel(INFO)
        self.logger.setLevel(INFO)
        self.logger.addHandler(handler)
        self.logger.propagate = False
        self.metrics = metric_names
        self.parser = TFEventFileParser()

    def parse_file(self, directory):
        mls = []
        for f in self.parser.find_all_files(directory):
            if tf.gfile.IsDirectory(f):
                continue
            try:
                self.logger.info(f + " will be parsed.")
                mls.extend(self.parser.parse_summary(f, self.metrics))
            except Exception, e:
                self.logger.warning("Unexpected error: " + str(e))
                continue
        return api_pb2.ObservationLog(metric_logs=mls)