diff --git a/trustgraph-flow/trustgraph/config/service/flow.py b/trustgraph-flow/trustgraph/config/service/flow.py index 867a2e0d..9d803213 100644 --- a/trustgraph-flow/trustgraph/config/service/flow.py +++ b/trustgraph-flow/trustgraph/config/service/flow.py @@ -64,7 +64,6 @@ class FlowConfig: async def handle_start_flow(self, msg): def repl_template(tmp): - print("REPL") return tmp.replace( "{class}", msg.class_name ).replace( @@ -83,17 +82,11 @@ class FlowConfig: variant = repl_template(variant) - print(">>", processor, variant) - - print(">>>", v) - v = { repl_template(k2): repl_template(v2) for k2, v2 in v.items() } - print("<<<", v) - if processor in self.config["flows-active"]: target = json.loads(self.config["flows-active"][processor]) else: @@ -104,10 +97,8 @@ class FlowConfig: self.config["flows-active"][processor] = json.dumps(target) - print(cls) - self.config["flows"][msg.flow_id] = { - "description": cls["description"], + "description": msg.description, "class-name": msg.class_name, } @@ -119,6 +110,51 @@ class FlowConfig: async def handle_stop_flow(self, msg): + def repl_template(tmp): + return tmp.replace( + "{class}", msg.class_name + ).replace( + "{id}", msg.flow_id + ) + + cls = json.loads(self.config["flow-classes"][msg.class_name]) + + plumb = {} + + for kind in ("flow"): + + for k, v in cls[kind].items(): + + processor, variant = k.split(":", 1) + + variant = repl_template(variant) + + if processor in self.config["flows-active"]: + target = json.loads(self.config["flows-active"][processor]) + else: + target = {} + + if variant in target: + del target[variant] + + self.config["flows-active"][processor] = json.dumps(target) + + if msg.flow_id in self.config["flows"]: + del self.config["flows"][msg.flow_id] + + await self.config.push() + + return FlowResponse( + error = None, + ) + + + + + + + + flow = self.config["flows"][msg.flow_id] return FlowResponse(