mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 19:51:02 +02:00
Flow start working
This commit is contained in:
parent
009878141f
commit
0fbe6f6676
1 changed files with 52 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
from trustgraph.schema import FlowResponse, Error
|
from trustgraph.schema import FlowResponse, Error
|
||||||
|
import json
|
||||||
|
|
||||||
class FlowConfig:
|
class FlowConfig:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
|
@ -26,6 +27,8 @@ class FlowConfig:
|
||||||
|
|
||||||
self.config["flow-classes"][msg.class_name] = msg.class_definition
|
self.config["flow-classes"][msg.class_name] = msg.class_definition
|
||||||
|
|
||||||
|
await self.config.push()
|
||||||
|
|
||||||
return FlowResponse(
|
return FlowResponse(
|
||||||
error = None,
|
error = None,
|
||||||
)
|
)
|
||||||
|
|
@ -34,6 +37,8 @@ class FlowConfig:
|
||||||
|
|
||||||
del self.config["flow-classes"][msg.class_name]
|
del self.config["flow-classes"][msg.class_name]
|
||||||
|
|
||||||
|
await self.config.push()
|
||||||
|
|
||||||
return FlowResponse(
|
return FlowResponse(
|
||||||
error = None,
|
error = None,
|
||||||
)
|
)
|
||||||
|
|
@ -58,10 +63,56 @@ class FlowConfig:
|
||||||
|
|
||||||
async def handle_start_flow(self, msg):
|
async def handle_start_flow(self, msg):
|
||||||
|
|
||||||
cls = self.config["flow-classes"][msg.class_name]
|
def repl_template(tmp):
|
||||||
|
print("REPL")
|
||||||
|
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 ("class", "flow"):
|
||||||
|
|
||||||
|
for k, v in cls[kind].items():
|
||||||
|
|
||||||
|
processor, variant = k.split(":", 1)
|
||||||
|
|
||||||
|
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:
|
||||||
|
target = {}
|
||||||
|
|
||||||
|
if variant not in target:
|
||||||
|
target[variant] = v
|
||||||
|
|
||||||
|
self.config["flows-active"][processor] = json.dumps(target)
|
||||||
|
|
||||||
print(cls)
|
print(cls)
|
||||||
|
|
||||||
|
self.config["flows"][msg.flow_id] = {
|
||||||
|
"description": cls["description"],
|
||||||
|
"class-name": msg.class_name,
|
||||||
|
}
|
||||||
|
|
||||||
|
await self.config.push()
|
||||||
|
|
||||||
return FlowResponse(
|
return FlowResponse(
|
||||||
error = None,
|
error = None,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue