def main():
    # Init.
    logging.basicConfig(
        level=logging.DEBUG)  # TODO(alessio): INFO once debugged.
    parser = collect_data.InstanceArgumentsParser()
    parser.add_argument('-f',
                        '--filename_suffix',
                        help=('suffix of the exported file'))
    parser.description = ('Exports pre-computed APM module quality assessment '
                          'results into HTML tables')
    args = parser.parse_args()

    # Get the scores.
    src_path = collect_data.ConstructSrcPath(args)
    logging.debug(src_path)
    scores_data_frame = collect_data.FindScores(src_path, args)

    # Export.
    output_filepath = os.path.join(args.output_dir,
                                   _BuildOutputFilename(args.filename_suffix))
    exporter = export.HtmlExport(output_filepath)
    exporter.Export(scores_data_frame)

    logging.info('output file successfully written in %s', output_filepath)
    sys.exit(0)
def main():
    # Init.
    logging.basicConfig(
        level=logging.DEBUG)  # TODO(alessio): INFO once debugged.
    parser = _InstanceArgumentsParser()
    args = parser.parse_args()

    # Get the scores.
    src_path = os.path.join(
        args.output_dir,
        sim.ApmModuleSimulator.GetPrefixApmConfig() + '*',
        sim.ApmModuleSimulator.GetPrefixCapture() + '*',
        sim.ApmModuleSimulator.GetPrefixRender() + '*',
        sim.ApmModuleSimulator.GetPrefixEchoSimulator() + '*',
        sim.ApmModuleSimulator.GetPrefixTestDataGenerator() + '*',
        sim.ApmModuleSimulator.GetPrefixTestDataGeneratorParameters() + '*',
        sim.ApmModuleSimulator.GetPrefixScore() + '*')
    logging.debug(src_path)
    scores_data_frame = _FindScores(src_path, args)

    # Export.
    output_filepath = os.path.join(args.output_dir,
                                   _BuildOutputFilename(args.filename_suffix))
    exporter = export.HtmlExport(output_filepath)
    exporter.Export(scores_data_frame)

    logging.info('output file successfully written in %s', output_filepath)
    sys.exit(0)
Exemplo n.º 3
0
def main():
    # Init.
    logging.basicConfig(
        level=logging.DEBUG)  # TODO(alessio): INFO once debugged.
    parser = _InstanceArgumentsParser()
    nested_dict = lambda: collections.defaultdict(nested_dict)
    scores = nested_dict()  # Organize the scores in a nested dictionary.

    # Parse command line arguments.
    args = parser.parse_args()

    # Find score files in the output path.
    src_path = os.path.join(args.output_dir, 'cfg-*', 'input-*', 'gen-*', '*',
                            'score-*.txt')
    logging.debug(src_path)
    for score_filepath in glob.iglob(src_path):
        # Extract score descriptors from the path.
        (config_name, input_name, test_data_gen_name, test_data_gen_params,
         score_name) = _GetScoreDescriptors(score_filepath)

        # Ignore the score if required.
        if _ExcludeScore(config_name, input_name, test_data_gen_name,
                         score_name, args):
            logging.info('ignored score: %s %s %s %s', config_name, input_name,
                         test_data_gen_name, score_name)
            continue

        # Get metadata.
        score_path, _ = os.path.split(score_filepath)
        audio_in_filepath, audio_ref_filepath = (
            data_access.Metadata.LoadAudioTestDataPaths(score_path))
        audio_out_filepath = os.path.abspath(
            os.path.join(score_path,
                         audioproc_wrapper.AudioProcWrapper.OUTPUT_FILENAME))

        # Add the score to the nested dictionary.
        scores[score_name][config_name][input_name][test_data_gen_name][
            test_data_gen_params] = {
                'score': data_access.ScoreFile.Load(score_filepath),
                'audio_in_filepath': audio_in_filepath,
                'audio_out_filepath': audio_out_filepath,
                'audio_ref_filepath': audio_ref_filepath,
            }

    # Export.
    output_filepath = os.path.join(args.output_dir,
                                   _BuildOutputFilename(args.filename_suffix))
    exporter = export.HtmlExport(output_filepath)
    exporter.Export(scores)

    logging.info('output file successfully written in %s', output_filepath)
    sys.exit(0)