Exemplo n.º 1
0
def create_report(attack_object_paths, save_path, pdf=False):
    """
    Create an attack report for all attacks.

    Parameters
    ----------
    attack_object_paths : dict
        Dictionary with attack alias and the corresponding path to the serialized attack
        object.
    save_path : str
        Path where to save the report files.
    pdf : bool
        If true, the attack runner will build the LaTex report and save an PDF to the
        save path.
    """
    os.makedirs(save_path + "/fig", exist_ok=True)
    sections = []
    for key, attack_obj_path in attack_object_paths.items():
        logger.debug(f"Try loading {key}")
        with open(attack_obj_path, "rb") as f_obj:
            attack = pickle.load(f_obj)

            logger.info(f"Create report subsection: {attack.attack_alias}")
            attack.create_attack_section(save_path)
            sections.append(attack.report_section)

    logger.info("Generate final report.")
    report.report_generator(save_path, sections, pdf=pdf)
    def create_attack_report(self, save_path="art_report", pdf=False):
        """
        Create an attack report just for the given attack instantiation.

        Parameters
        ----------
        save_path : str
            Path to save the tex, pdf and asset files of the attack report.
        pdf : bool
            If set, generate pdf out of latex file.
        """

        # Create directory structure for the attack report, including the figure
        # directory for the figures of the results subsubsection.
        os.makedirs(save_path + "/fig", exist_ok=True)

        self.create_attack_section(save_path)
        report.report_generator(save_path, [self.report_section], pdf)