mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
* Tech spec * Python CLI utilities updated to use the API including streaming features * Added type safety to Python API * Completed missing auth token support in CLI
60 lines
No EOL
1.1 KiB
Python
60 lines
No EOL
1.1 KiB
Python
"""
|
|
Stops a processing flow.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import tabulate
|
|
from trustgraph.api import Api
|
|
import json
|
|
|
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
|
|
|
def stop_flow(url, flow_id, token=None):
|
|
|
|
api = Api(url, token=token).flow()
|
|
|
|
api.stop(id = flow_id)
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog='tg-stop-flow',
|
|
description=__doc__,
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-u', '--api-url',
|
|
default=default_url,
|
|
help=f'API URL (default: {default_url})',
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-t', '--token',
|
|
default=default_token,
|
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-i', '--flow-id',
|
|
required=True,
|
|
help=f'Flow ID',
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
|
|
stop_flow(
|
|
url=args.api_url,
|
|
flow_id=args.flow_id,
|
|
token=args.token,
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
print("Exception:", e, flush=True)
|
|
|
|
if __name__ == "__main__":
|
|
main() |