def _check_infinite_flows(self, flow_config, visited_flows=None): """ Recursively loop through the flow_config and check if there are any cycles. :param steps: Set of step definitions to loop through :param flows: Flows already visited. :return: None """ if visited_flows is None: visited_flows = set() project_config = flow_config.project_config for step in flow_config.steps.values(): if "flow" in step: flow_name = step["flow"] if flow_name == "None": continue next_flow_config = project_config.get_flow(flow_name) signature = ( hash(next_flow_config.project_config.source), next_flow_config.name, ) if signature in visited_flows: raise FlowInfiniteLoopError( f"Infinite flows detected with flow {flow_name}") visited_flows.add(signature) self._check_infinite_flows(next_flow_config, visited_flows)
def _check_infinite_flows(self, steps, flows=None): if flows == None: flows = [] for step in steps.values(): if "flow" in step: flow = step["flow"] if flow in flows: raise FlowInfiniteLoopError( "Infinite flows detected with flow {}".format(flow)) flows.append(flow) flow_config = self.project_config.get_flow(flow) self._check_infinite_flows(flow_config.steps, flows)
def _check_infinite_flows(self, steps, flows=None): """ Recursively loop through the flow_config and check if there are any cycles. :param steps: Set of step definitions to loop through :param flows: Flows already visited. :return: None """ if flows is None: flows = [] for step in steps.values(): if "flow" in step: flow = step["flow"] if flow == "None": continue if flow in flows: raise FlowInfiniteLoopError( "Infinite flows detected with flow {}".format(flow)) flows.append(flow) flow_config = self.project_config.get_flow(flow) self._check_infinite_flows(flow_config.steps, flows)