def get_metrics(campaign, report, top=True):
if top and campaign.process.type == '<STR_LIT>':<EOL><INDENT>for path, _ in report.collect('<STR_LIT>', with_path=True):<EOL><INDENT>for child in ReportNode(path).children.values():<EOL><INDENT>for metrics in get_metrics(campaign, child, top=False):<EOL><INDENT>yield metrics<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>def metrics_node_extract(report):<EOL><INDENT>metrics_file = osp.join(report.path, JSON_METRICS_FILE)<EOL>if osp.exists(metrics_file):<EOL><INDENT>with open(metrics_file) as istr:<EOL><INDENT>return json.load(istr)<EOL><DEDENT><DEDENT><DEDENT>def metrics_iterator(report):<EOL><INDENT>return filter(<EOL>lambda eax: eax[<NUM_LIT:1>] is not None,<EOL>report.map(metrics_node_extract, with_path=True),<EOL>)<EOL><DEDENT>for path, metrics in metrics_iterator(report):<EOL><INDENT>yield report.path_context(path), metrics<EOL><DEDENT><DEDENT>
Extract metrics from existing campaign

    :param campaign: campaign loaded with `hpcbench.campaign.from_file`
    :param report: instance of `hpcbench.campaign.ReportNode`
    :param top: this function is recursive. This parameter
    help distinguishing top-call.