mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 01:16:22 +02:00
Flow class / flow blueprint
This commit is contained in:
parent
99f17d1b9d
commit
95fd60b7bd
11 changed files with 118 additions and 116 deletions
|
|
@ -29,13 +29,13 @@ Homepage = "https://github.com/trustgraph-ai/trustgraph"
|
|||
|
||||
[project.scripts]
|
||||
tg-add-library-document = "trustgraph.cli.add_library_document:main"
|
||||
tg-delete-flow-class = "trustgraph.cli.delete_flow_class:main"
|
||||
tg-delete-flow-blueprint = "trustgraph.cli.delete_flow_blueprint:main"
|
||||
tg-delete-mcp-tool = "trustgraph.cli.delete_mcp_tool:main"
|
||||
tg-delete-kg-core = "trustgraph.cli.delete_kg_core:main"
|
||||
tg-delete-tool = "trustgraph.cli.delete_tool:main"
|
||||
tg-dump-msgpack = "trustgraph.cli.dump_msgpack:main"
|
||||
tg-dump-queues = "trustgraph.cli.dump_queues:main"
|
||||
tg-get-flow-class = "trustgraph.cli.get_flow_class:main"
|
||||
tg-get-flow-blueprint = "trustgraph.cli.get_flow_blueprint:main"
|
||||
tg-get-kg-core = "trustgraph.cli.get_kg_core:main"
|
||||
tg-graph-to-turtle = "trustgraph.cli.graph_to_turtle:main"
|
||||
tg-init-trustgraph = "trustgraph.cli.init_trustgraph:main"
|
||||
|
|
@ -56,7 +56,7 @@ tg-load-text = "trustgraph.cli.load_text:main"
|
|||
tg-load-turtle = "trustgraph.cli.load_turtle:main"
|
||||
tg-load-knowledge = "trustgraph.cli.load_knowledge:main"
|
||||
tg-load-structured-data = "trustgraph.cli.load_structured_data:main"
|
||||
tg-put-flow-class = "trustgraph.cli.put_flow_class:main"
|
||||
tg-put-flow-blueprint = "trustgraph.cli.put_flow_blueprint:main"
|
||||
tg-put-kg-core = "trustgraph.cli.put_kg_core:main"
|
||||
tg-remove-library-document = "trustgraph.cli.remove_library_document:main"
|
||||
tg-save-doc-embeds = "trustgraph.cli.save_doc_embeds:main"
|
||||
|
|
@ -65,7 +65,7 @@ tg-set-prompt = "trustgraph.cli.set_prompt:main"
|
|||
tg-set-token-costs = "trustgraph.cli.set_token_costs:main"
|
||||
tg-set-tool = "trustgraph.cli.set_tool:main"
|
||||
tg-show-config = "trustgraph.cli.show_config:main"
|
||||
tg-show-flow-classes = "trustgraph.cli.show_flow_classes:main"
|
||||
tg-show-flow-blueprints = "trustgraph.cli.show_flow_blueprints:main"
|
||||
tg-show-flow-state = "trustgraph.cli.show_flow_state:main"
|
||||
tg-show-flows = "trustgraph.cli.show_flows:main"
|
||||
tg-show-graph = "trustgraph.cli.show_graph:main"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Deletes a flow class
|
||||
Deletes a flow blueprint
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
|
@ -10,16 +10,16 @@ import json
|
|||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
|
||||
def delete_flow_class(url, class_name):
|
||||
def delete_flow_blueprint(url, blueprint_name):
|
||||
|
||||
api = Api(url).flow()
|
||||
|
||||
class_names = api.delete_class(class_name)
|
||||
blueprint_names = api.delete_blueprint(blueprint_name)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='tg-delete-flow-class',
|
||||
prog='tg-delete-flow-blueprint',
|
||||
description=__doc__,
|
||||
)
|
||||
|
||||
|
|
@ -30,17 +30,17 @@ def main():
|
|||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-n', '--class-name',
|
||||
help=f'Flow class name',
|
||||
'-n', '--blueprint-name',
|
||||
help=f'Flow blueprint name',
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
|
||||
delete_flow_class(
|
||||
delete_flow_blueprint(
|
||||
url=args.api_url,
|
||||
class_name=args.class_name,
|
||||
blueprint_name=args.blueprint_name,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
@ -48,4 +48,4 @@ def main():
|
|||
print("Exception:", e, flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Outputs a flow class definition in JSON format.
|
||||
Outputs a flow blueprint definition in JSON format.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
|
@ -10,18 +10,18 @@ import json
|
|||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
|
||||
def get_flow_class(url, class_name):
|
||||
def get_flow_blueprint(url, blueprint_name):
|
||||
|
||||
api = Api(url).flow()
|
||||
|
||||
cls = api.get_class(class_name)
|
||||
cls = api.get_blueprint(blueprint_name)
|
||||
|
||||
print(json.dumps(cls, indent=4))
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='tg-get-flow-class',
|
||||
prog='tg-get-flow-blueprint',
|
||||
description=__doc__,
|
||||
)
|
||||
|
||||
|
|
@ -32,18 +32,18 @@ def main():
|
|||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-n', '--class-name',
|
||||
'-n', '--blueprint-name',
|
||||
required=True,
|
||||
help=f'Flow class name',
|
||||
help=f'Flow blueprint name',
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
|
||||
get_flow_class(
|
||||
get_flow_blueprint(
|
||||
url=args.api_url,
|
||||
class_name=args.class_name,
|
||||
blueprint_name=args.blueprint_name,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
@ -51,4 +51,4 @@ def main():
|
|||
print("Exception:", e, flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Uploads a flow class definition. You can take the output of
|
||||
tg-get-flow-class and load it back in using this utility.
|
||||
Uploads a flow blueprint definition. You can take the output of
|
||||
tg-get-flow-blueprint and load it back in using this utility.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
|
@ -11,16 +11,16 @@ import json
|
|||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
|
||||
def put_flow_class(url, class_name, config, token=None):
|
||||
def put_flow_blueprint(url, blueprint_name, config, token=None):
|
||||
|
||||
api = Api(url, token=token)
|
||||
|
||||
class_names = api.flow().put_class(class_name, config)
|
||||
blueprint_names = api.flow().put_blueprint(blueprint_name, config)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='tg-put-flow-class',
|
||||
prog='tg-put-flow-blueprint',
|
||||
description=__doc__,
|
||||
)
|
||||
|
||||
|
|
@ -37,8 +37,8 @@ def main():
|
|||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-n', '--class-name',
|
||||
help=f'Flow class name',
|
||||
'-n', '--blueprint-name',
|
||||
help=f'Flow blueprint name',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
|
@ -50,9 +50,9 @@ def main():
|
|||
|
||||
try:
|
||||
|
||||
put_flow_class(
|
||||
put_flow_blueprint(
|
||||
url=args.api_url,
|
||||
class_name=args.class_name,
|
||||
blueprint_name=args.blueprint_name,
|
||||
config=json.loads(args.config),
|
||||
token=args.token,
|
||||
)
|
||||
|
|
@ -62,4 +62,4 @@ def main():
|
|||
print("Exception:", e, flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Shows all defined flow classes.
|
||||
Shows all defined flow blueprints.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
|
@ -16,7 +16,7 @@ def format_parameters(params_metadata, config_api):
|
|||
Format parameter metadata for display
|
||||
|
||||
Args:
|
||||
params_metadata: Parameter definitions from flow class
|
||||
params_metadata: Parameter definitions from flow blueprint
|
||||
config_api: API client to get parameter type information
|
||||
|
||||
Returns:
|
||||
|
|
@ -58,23 +58,23 @@ def format_parameters(params_metadata, config_api):
|
|||
|
||||
return "\n".join(param_list)
|
||||
|
||||
def show_flow_classes(url, token=None):
|
||||
def show_flow_blueprints(url, token=None):
|
||||
|
||||
api = Api(url, token=token)
|
||||
flow_api = api.flow()
|
||||
config_api = api.config()
|
||||
|
||||
class_names = flow_api.list_classes()
|
||||
blueprint_names = flow_api.list_blueprints()
|
||||
|
||||
if len(class_names) == 0:
|
||||
print("No flow classes.")
|
||||
if len(blueprint_names) == 0:
|
||||
print("No flow blueprints.")
|
||||
return
|
||||
|
||||
for class_name in class_names:
|
||||
cls = flow_api.get_class(class_name)
|
||||
for blueprint_name in blueprint_names:
|
||||
cls = flow_api.get_blueprint(blueprint_name)
|
||||
|
||||
table = []
|
||||
table.append(("name", class_name))
|
||||
table.append(("name", blueprint_name))
|
||||
table.append(("description", cls.get("description", "")))
|
||||
|
||||
tags = cls.get("tags", [])
|
||||
|
|
@ -97,7 +97,7 @@ def show_flow_classes(url, token=None):
|
|||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='tg-show-flow-classes',
|
||||
prog='tg-show-flow-blueprints',
|
||||
description=__doc__,
|
||||
)
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ def main():
|
|||
|
||||
try:
|
||||
|
||||
show_flow_classes(
|
||||
show_flow_blueprints(
|
||||
url=args.api_url,
|
||||
token=args.token,
|
||||
)
|
||||
|
|
@ -127,4 +127,4 @@ def main():
|
|||
print("Exception:", e, flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue