dump data for an individual metric. For internal use only.
194652
def _dump(self):
        """"""

        try:
            self.temp.seek(0) # seek to beginning
            arr = np.fromfile(self.temp, self.dtype)
            self.count_arr = arr['count']
            self.elapsed_arr = arr['elapsed']

            if self.calc_stats:
                # calculate mean & standard deviation
                self.count_mean = np.mean(self.count_arr)
                self.count_std = np.std(self.count_arr)
                self.elapsed_mean = np.mean(self.elapsed_arr)
                self.elapsed_std = np.std(self.elapsed_arr)

            self._output()
        finally:
            self.temp.close()
            self._cleanup()
943280
def _publish_metrics(self, prev_keys, key, data, publishfn=None):
        """"""
        if key not in data:
            return
        value = data[key]
        keys = prev_keys + [key]
        if not publishfn:
            publishfn = self.publish
        if isinstance(value, dict):
            for new_key in value:
                self._publish_metrics(keys, new_key, value)
        elif isinstance(value, int) or isinstance(value, float):
            publishfn('.'.join(keys), value)
        elif isinstance(value, long):
            publishfn('.'.join(keys), float(value))
131839
static Map<String, Double> processMetrics(String prefix, Iterable<MetricsInfo> metrics) {
    Map<String, Double> map = new HashMap<>();
    for (MetricsInfo r : metrics) {
      try {
        map.put(prefix + r.getName(), Double.valueOf(r.getValue()));
      } catch (NumberFormatException ne) {
        LOG.log(Level.SEVERE, "Could not parse metric, Name: "
            + r.getName() + " Value: " + r.getValue(), ne);
      }
    }
    return map;
  }
603572
def output_results(results, metric, options):
    
    formatter = options['Formatter']
    context = metric.copy()  # XXX might need to sanitize this
    try:
        context['dimension'] = list(metric['Dimensions'].values())[0]
    except AttributeError:
        context['dimension'] = ''
    for result in results:
        stat_keys = metric['Statistics']
        if not isinstance(stat_keys, list):
            stat_keys = [stat_keys]
        for statistic in stat_keys:
            context['statistic'] = statistic
            # get and then sanitize metric name, first copy the unit name from the
            # result to the context to keep the default format happy
            context['Unit'] = result['Unit']
            metric_name = (formatter % context).replace('/', '.').lower()
            line = '{0} {1} {2}\n'.format(
                metric_name,
                result[statistic],
                timegm(result['Timestamp'].timetuple()),
            )
            sys.stdout.write(line)
585896
def dump_conndata(self):
        """"""
        attrs = vars(self)
        return ', '.join("%s: %s" % item for item in attrs.items())
661519
def format(file_metrics, build_metrics):
    """"""
    # TODO maybe we need different output for build_metrics in csv format, too?
    # filter out positions metric
    def report_header(file_metrics):
        values = list(file_metrics.values())[0]
        print(values)
        values.pop('block_positions', None)
        return 'filename,' + ','.join(values) + '\n'

    def report_metrics(file_metrics):
        report = ''
        for key, values in file_metrics.items():
            report += key + ','
            report += ','.join([str(v) for k, v in values.items() if k not in ['block_positions']])
            report += '\n'
        return report

    report = report_header(file_metrics)
    report += report_metrics(file_metrics)
    return report
1309077
def save_data(self, idx):
        """"""
        for name in self:
            actual = getattr(self, name)
            diskflag = getattr(self, '_%s_diskflag' % name)
            ramflag = getattr(self, '_%s_ramflag' % name)
            if diskflag:
                file_ = getattr(self, '_%s_file' % name)
                ndim = getattr(self, '_%s_ndim' % name)
                length_tot = 1
                for jdx in range(ndim):
                    length = getattr(self, '_%s_length_%s' % (name, jdx))
                    length_tot *= length
                if ndim:
                    raw = struct.pack(length_tot*'d', *actual.flatten())
                else:
                    raw = struct.pack('d', actual)
                file_.write(raw)
            elif ramflag:
                array = getattr(self, '_%s_array' % name)
                array[idx] = actual
1167484
def dumpdata(app_target, *args, **kwargs):
    """"""
    options = {
        '--indent': 4,
    }
    options.update(kwargs)

    # Quiet down pynt...
    logger = logging.getLogger('pynt')
    logger.propagate = False

    project.execute_manage('dumpdata', app_target, *args, **options)
992029
def _resource_dump(pe, res):
    """"""
    rva = res.data.struct.OffsetToData
    size = res.data.struct.Size

    dump = pe.get_data(rva, size)
    return dump
865461
def write(self, name, **data):
        

        data["name"] = name
        if not ("timestamp" in data):
            data["timestamp"] = datetime.utcnow()

        try:
            self.client.index(
                index=self.get_index(),
                doc_type=self.doc_type,
                id=None,
                body=data
            )
        except TransportError as exc:
            logger.warning('writing metric %r failure %r', data, exc)
184422
def dump_results(self):
        
        system = self.system
        mu = self.mu
        partfact = self.part_fact

        if system.files.no_output:
            return

        text = []
        header = []
        rowname = []
        data = []

        neig = len(mu)
        mu_real = mu.real()
        mu_imag = mu.imag()
        npositive = sum(1 for x in mu_real if x > 0)
        nzero = sum(1 for x in mu_real if x == 0)
        nnegative = sum(1 for x in mu_real if x < 0)

        numeral = []
        for idx, item in enumerate(range(neig)):
            if mu_real[idx] == 0:
                marker = '*'
            elif mu_real[idx] > 0:
                marker = '**'
            else:
                marker = ''
            numeral.append('#' + str(idx + 1) + marker)

        # compute frequency, undamped frequency and damping
        freq = [0] * neig
        ufreq = [0] * neig
        damping = [0] * neig
        for idx, item in enumerate(mu):
            if item.imag == 0:
                freq[idx] = 0
                ufreq[idx] = 0
                damping[idx] = 0
            else:
                freq[idx] = abs(item) / 2 / pi
                ufreq[idx] = abs(item.imag / 2 / pi)
                damping[idx] = -div(item.real, abs(item)) * 100

        # obtain most associated variables
        var_assoc = []
        for prow in range(neig):
            temp_row = partfact[prow, :]
            name_idx = list(temp_row).index(max(temp_row))
            var_assoc.append(system.varname.unamex[name_idx])

        pf = []
        for prow in range(neig):
            temp_row = []
            for pcol in range(neig):
                temp_row.append(round(partfact[prow, pcol], 5))
            pf.append(temp_row)

        text.append(system.report.info)
        header.append([''])
        rowname.append(['EIGENVALUE ANALYSIS REPORT'])
        data.append('')

        text.append('STATISTICS\n')
        header.append([''])
        rowname.append(['Positives', 'Zeros', 'Negatives'])
        data.append([npositive, nzero, nnegative])

        text.append('EIGENVALUE DATA\n')
        header.append([
            'Most Associated', 'Real', 'Imag', 'Damped Freq.', 'Frequency',
            'Damping [%]'
        ])
        rowname.append(numeral)
        data.append(
            [var_assoc,
             list(mu_real),
             list(mu_imag), ufreq, freq, damping])

        cpb = 7  # columns per block
        nblock = int(ceil(neig / cpb))

        if nblock <= 100:
            for idx in range(nblock):
                start = cpb * idx
                end = cpb * (idx + 1)
                text.append('PARTICIPATION FACTORS [{}/{}]\n'.format(
                    idx + 1, nblock))
                header.append(numeral[start:end])
                rowname.append(system.varname.unamex)
                data.append(pf[start:end])

        dump_data(text, header, rowname, data, system.files.eig)
        logger.info('report saved.')
43648
def dump(self):
        """"""
        text = ''

        for result in self.objects:
            if result.is_failure or result.is_error:
                text += '\n#{red}#{bright}'
                text += '{}\n'.format(''.ljust(79, '='))

                status = 'FAILED' if result.is_failure else 'ERROR'
                text += '{}: {}\n'.format(status, result.process)
                text += '{}\n#{{reset_all}}'.format(''.ljust(79, '='))

                if result.output:
                    text += result.output

                if result.error:
                    if result.output:
                        text += '\n{}\n'.format(''.ljust(79, '-'))
                        text += 'Additional error output:\n'
                        text += '{}\n'.format(''.ljust(79, '-'))
                    text += result.error

                if not text.endswith('\n'):
                    text += '\n'

        if self.has_modified_files:
            text += '\n#{{yellow}}#{{bright}}{}\n'.format(''.ljust(79, '-'))
            text += 'Modified files:\n'
            text += '{}\n'.format(''.ljust(79, '-'))
            for path, modified_by in self.modified_files:
                text += '#{{reset_all}}{} #{{cyan}}<- {}\n'.format(path, ', '.join(modified_by))

        return text
786019
def summarize_metrics(eval_metrics_writer, metrics, epoch):
  """"""
  for (name, value) in six.iteritems(metrics):
    summary = tf.Summary()
    summary.value.add(tag=name, simple_value=value)
    eval_metrics_writer.add_summary(summary, epoch)
  eval_metrics_writer.flush()
1344797
def do_metric_create_raw(mc, args):
    ''''''
    try:
        mc.metrics.create(**args.jsonbody)
    except (osc_exc.ClientException, k_exc.HttpError) as he:
        raise osc_exc.CommandError('%s\n%s' % (he.message, he.details))
    else:
        print('Successfully created metric')
143044
def safe_dump(data, stream=None, **kwds):
    """"""
    return yaml.dump(data, stream=stream, Dumper=ODYD, **kwds)
38347
def dumpStatsTo(filename):
  """"""
  with open(filename, 'w') as f:
    latest = getStats()
    latest['last-updated'] = time.time()
    json.dump(getStats(), f, cls=StatContainerEncoder)
798563
def metric(cls, name, count, elapsed):
        

        if name is None:
            warnings.warn("Ignoring unnamed metric", stacklevel=3)
            return

        with cls.lock:
            if not cls.instances:
                # first call
                shutil.rmtree(cls.outdir, ignore_errors=True)
                os.makedirs(cls.outdir)

                if cls.dump_atexit: atexit.register(cls.dump)

            try:
                self = cls.instances[name]
            except KeyError:
                self = cls.instances[name] = cls(name)

            self.writer.writerow((count, "%f"%elapsed))