diff --git a/src/dvsim/flow/one_shot.py b/src/dvsim/flow/one_shot.py index c717eea2..4505b867 100644 --- a/src/dvsim/flow/one_shot.py +++ b/src/dvsim/flow/one_shot.py @@ -171,13 +171,32 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None: for item in self.cfgs: project = item.name + # We want to report all the results with the correct block + # (checking the name) and also with the correct variant. + # + # For the latter check, we don't necessarily know that item (the + # configuration that is being run) is a type that defines variant + # at all. If not, we just interpret the variant as None. + item_variant = getattr(item, "variant", None) + + # The typing of the configuration also doesn't guarantee it has a + # _gen_results function, which we will need here. Check that it + # really exists: if not, we'll have to fail at runtime. + gen_results_fun = getattr(item, "_gen_results", None) + if not gen_results_fun: + msg = ( + f"Cannot generate results for FlowCfg {item.name}: " + "not an instance of a class that defines _gen_results" + ) + raise RuntimeError(msg) + item_results = [ res for res in results - if res.block.name == item.name and res.block.variant == item.variant + if res.block.name == item.name and res.block.variant == item_variant ] - result = item._gen_results(item_results) + result = gen_results_fun(item_results) log.info("[results]: [%s]:\n%s\n", project, result) log.info("[scratch_path]: [%s] [%s]", project, item.scratch_path)