<commit_before>#!/usr/bin/env python


def main():

    import argparse
    from qap.script_utils import gather_json_info, json_to_csv

    parser = argparse.ArgumentParser()
    parser.add_argument("output_dir", type=str,
                        help="the main output directory of the QAP run")
    parser.add_argument("--with_reports", action='store_true',
                        default=False, help="Write a summary report in PDF "
                        "format.")

    args = parser.parse_args()

    json_dict = gather_json_info(args.output_dir)
    json_to_csv(json_dict)

    if args.with_reports:
        from qap.viz.reports import workflow_report
        # TODO: read in combined results dictionary from log JSONs
        #logs_dict = gather_json_info("_".join([args.output_dir, "logs"]))
        # TODO: get a handle for the three CSVs, do checks

        qap_types = ["anatomical_spatial",
                     "functional_spatial",
                     "functional_temporal"]
        for qap_type in qap_types:
            qap_type = "_".join(["qap", qap_type])
            in_csv = op.join(config['output_directory'],
                             '%s.csv' % qap_type)
            reports = workflow_report(in_csv, qap_type, self._run_name,
                                      out_dir=config['output_directory'])


if __name__ == "__main__":
    main()<commit_msg>Moved reports to qap_jsons_to_csv script.<commit_after>#!/usr/bin/env python


def main():

    import os
    import argparse
    from qap.script_utils import gather_json_info, json_to_csv
    from qap.workflow_utils import raise_smart_exception

    parser = argparse.ArgumentParser()
    parser.add_argument("output_dir", type=str,
                        help="the main output directory of the QAP run "
                        "which contains the participant directories")
    parser.add_argument("--with_reports", action='store_true',
                        default=False, help="Write a summary report in PDF "
                        "format.")

    args = parser.parse_args()

    json_dict = gather_json_info(args.output_dir)
    json_to_csv(json_dict)

    if args.with_reports:
        from qap.viz.reports import workflow_report
        # TODO: read in combined results dictionary from log JSONs
        #logs_dict = gather_json_info("_".join([args.output_dir, "logs"]))

        qap_types = ["anatomical_spatial",
                     "functional_spatial",
                     "functional_temporal"]
        for qap_type in qap_types:
            qap_type = "_".join(["qap", qap_type])
            run_name = args.output_dir.split("/")[-1]
            in_csv = op.join(os.getcwd(), '%s.csv' % qap_type)
            if os.path.isfile(in_csv):
                err = "[!] The %s CSV file was not successfully created." \
                      % qap_type
                raise_smart_exception(locals(), err)
            reports = workflow_report(in_csv, qap_type, run_name,
                                      out_dir=args.output_dir)


if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.09876140808344198, 'fraction_numerical': 0.0003259452411994785, 'mean_word_length': 2.1094224924012157, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '331146', 'n_tokens_mistral': 931, 'n_tokens_neox': 874, 'n_words': 200}