2025-04-24 19:02:51 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
"""
|
2025-05-06 13:43:17 +01:00
|
|
|
Starts a processing flow using a defined flow class
|
2025-04-24 19:02:51 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import os
|
|
|
|
|
import tabulate
|
|
|
|
|
from trustgraph.api import Api
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
|
|
|
|
|
|
|
|
def start_flow(url, class_name, flow_id, description):
|
|
|
|
|
|
2025-05-05 11:09:18 +01:00
|
|
|
api = Api(url).flow()
|
2025-04-24 19:02:51 +01:00
|
|
|
|
2025-05-05 11:09:18 +01:00
|
|
|
api.start(
|
2025-04-24 19:02:51 +01:00
|
|
|
class_name = class_name,
|
|
|
|
|
id = flow_id,
|
|
|
|
|
description = description,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
prog='tg-start-flow',
|
|
|
|
|
description=__doc__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-u', '--api-url',
|
|
|
|
|
default=default_url,
|
|
|
|
|
help=f'API URL (default: {default_url})',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-n', '--class-name',
|
|
|
|
|
required=True,
|
|
|
|
|
help=f'Flow class name',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-i', '--flow-id',
|
|
|
|
|
required=True,
|
|
|
|
|
help=f'Flow ID',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-d', '--description',
|
|
|
|
|
required=True,
|
|
|
|
|
help=f'Flow description',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
start_flow(
|
|
|
|
|
url = args.api_url,
|
|
|
|
|
class_name = args.class_name,
|
|
|
|
|
flow_id = args.flow_id,
|
|
|
|
|
description = args.description,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
|
|
print("Exception:", e, flush=True)
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|