def print_results(analyzers: List[str], results_all, out: str): base = os.path.join(out, "statistics") yaml_data = dtu.yaml_dump_pretty(results_all) dtu.write_str_to_file(yaml_data, os.path.join(base, "statistics.yaml")) print((dtu.indent(yaml_data, "print_results "))) for a in analyzers: dtu.write_str_to_file(dtu.yaml_dump_pretty(results_all[a]), os.path.join(base, f"{a}.table.yaml")) s = "" s += "\n" + "-" * 10 + f" Results for {a} " + "-" * 10 table = table_for_analyzer(results_all[a]) s += "\n" + dtu.indent(dtu.format_table_plus(table, colspacing=3), " ") s += "\n" dtu.write_str_to_file(s, os.path.join(base, f"{a}.table.txt"))
def yaml_representation_of_phy_logs(logs: Dict[str, PhysicalLog]) -> str: dtu.check_isinstance(logs, dict) res = {} for k, l in list(logs.items()): res[k] = yaml_from_physical_log(l) s = dtu.yaml_dump_pretty(res) return s
def __init__( self, logs, processors: Optional[List[object]] = None, analyzers: Optional[List[str]] = None, checks: Optional[List[str]] = None, topic_videos: Optional[List[str]] = None, topic_images: Optional[List[str]] = None, ): processors = processors or [] analyzers = analyzers or [] checks = checks or [] topic_videos = topic_videos or [] topic_images = topic_images or [] self.logs = logs self.processors = [] for p in processors: p = copy.deepcopy(p) processor = p.pop("processor") prefix_in = p.pop("prefix_in", "") prefix_out = p.pop("prefix_out", "") if p: msg = f"Extra keys: {p}" raise ValueError(msg) p2 = ProcessorEntry(prefix_in=prefix_in, processor=processor, prefix_out=prefix_out) self.processors.append(p2) self.analyzers = analyzers self.topic_videos = topic_videos self.topic_images = topic_images check_isinstance(checks, list) try: self.cwcs = parse_list_of_checks(checks) except RTParseError as e: msg = "Cannot parse list of checks." msg += "\n" + dtu.indent(dtu.yaml_dump_pretty(checks), "", "parsing: ") dtu.raise_wrapped(RTParseError, e, msg, compact=True)
def format_instances(family, colorize, verbose=False): if not family.instances: s = ( f'No instances files found for family "{family.family_name}" (pattern = ' f"{family.instances_pattern}).\n\n") return s else: s = f'Found {len(family.instances)} instances of algorithm family "{family.family_name}":\n' table = [] table.append([ "Instance name", "constructor", "parameters", "description", "filename" ]) for _ in list(family.instances.values()): row = [] name = _.instance_name if (not _.valid) and colorize: name = dtu.make_red(name) row.append(name) row.append(_.constructor) row.append(dtu.yaml_dump_pretty(_.parameters)) row.append(_.description) row.append(dtu.friendly_path(_.filename)) table.append(row) if not verbose: dtu.remove_table_field(table, "filename") dtu.remove_table_field(table, "description") s += dtu.indent(dtu.format_table_plus(table, colspacing=4), "| ") for _ in list(family.instances.values()): if not _.valid: msg = _.error_if_invalid s += dtu.make_red("\n" + dtu.indent(msg, "", _.instance_name + ": ")) return s
def yaml_from_rdbe(r: ResultDBEntry) -> str: d = {} d["description"] = "The result of running a unit test" d["constructor"] = "easy_regression.rdbe_from_yaml" d["parameters"] = r._asdict() return dtu.yaml_dump_pretty(d)