def compile(self, bi_searcher: ABCBISearcher) -> BICompiledAggregation: compiled_branches: List[BICompiledRule] = [] if not self.computation_options.disabled: branches = self.node.compile({}, bi_searcher) # Each sub-branch represents one BI Aggregation with an unique name # The postprocessing phase takes care of the "remaining services" action for branch in branches: services_of_host: Dict[HostName, Set[ServiceName]] = {} for _site, host_name, service_description in branch.required_elements( ): if service_description is None: continue services_of_host.setdefault(host_name, set()).add(service_description) branch.compile_postprocess(branch, services_of_host, bi_searcher) compiled_branches = self._verify_all_branches_start_with_rule( branches) return BICompiledAggregation( self.id, compiled_branches, self.computation_options, self.aggregation_visualization, self.groups, )
def create_trees_from_schema(cls, schema_config: Dict[str, Any]) -> BICompiledAggregation: branches = [BIRule.create_tree_from_schema(config) for config in schema_config["branches"]] aggregation_id = schema_config["id"] computation_options = BIAggregationComputationOptions(schema_config["computation_options"]) aggregation_visualization = schema_config["aggregation_visualization"] groups = BIAggregationGroups(schema_config["groups"]) return BICompiledAggregation(aggregation_id, branches, computation_options, aggregation_visualization, groups)
def _get_legacy_branch(self, compiled_aggregation: BICompiledAggregation, node_result_bundle: NodeResultBundle, aggr_group: str) -> Dict: title = node_result_bundle.instance.properties.title if title not in self._legacy_branch_cache: legacy_branch = compiled_aggregation.convert_result_to_legacy_format(node_result_bundle) self._legacy_branch_cache[title] = legacy_branch else: legacy_branch = copy.deepcopy(self._legacy_branch_cache[title]) legacy_branch["aggr_group"] = aggr_group return legacy_branch
def compile(self) -> BICompiledAggregation: branches = self.node.compile({}) # Each sub-branch represents one BI Aggregation with an unique name # Postprocessing takes care of the "remaining services" action for branch in branches: branch.compile_postprocess(branch) verified_branches = self._verify_all_branches_start_with_rule(branches) return BICompiledAggregation( self.id, verified_branches, self.computation_options, self.aggregation_visualization, self.groups, )
def compile(self, bi_searcher: ABCBISearcher) -> BICompiledAggregation: compiled_branches: List[BICompiledRule] = [] if not self.computation_options.disabled: branches = self.node.compile({}, bi_searcher) # Each sub-branch represents one BI Aggregation with an unique name # The postprocessing phase takes care of the "remaining services" action for branch in branches: branch.compile_postprocess(branch, bi_searcher) compiled_branches = self._verify_all_branches_start_with_rule(branches) return BICompiledAggregation( self.id, compiled_branches, self.computation_options, self.aggregation_visualization, self.groups, )