mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 20:21:03 +02:00
New flow command
This commit is contained in:
parent
d0cc173112
commit
ff92d6886f
2 changed files with 23 additions and 9 deletions
|
|
@ -6,35 +6,48 @@ Dump out TrustGraph processor states.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import argparse
|
import argparse
|
||||||
|
import json
|
||||||
|
|
||||||
default_metrics_url = "http://localhost:8088/api/metrics"
|
default_metrics_url = "http://localhost:8088/api/metrics"
|
||||||
|
|
||||||
def dump_status(url):
|
def dump_status(url, flow_id):
|
||||||
|
|
||||||
url = f"{url}/query?query=processor_info"
|
url = f"{url}/query"
|
||||||
|
|
||||||
resp = requests.get(url)
|
expr = f"consumer_state=\"running\",flow=\"{flow_id}\""
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"query": "consumer_state{" + expr + "}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resp = requests.get(url, params=params)
|
||||||
|
|
||||||
obj = resp.json()
|
obj = resp.json()
|
||||||
|
|
||||||
tbl = [
|
tbl = [
|
||||||
[
|
[
|
||||||
m["metric"]["job"],
|
m["metric"]["job"],
|
||||||
"\U0001f49a"
|
"\U0001f49a" if int(m["value"][1]) > 0 else "\U0000274c"
|
||||||
]
|
]
|
||||||
for m in obj["data"]["result"]
|
for m in obj["data"]["result"]
|
||||||
]
|
]
|
||||||
|
|
||||||
for row in tbl:
|
for row in tbl:
|
||||||
print(f" {row[0]:30} {row[1]}")
|
print(f"- {row[0]:30} {row[1]}")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='tg-processor-state',
|
prog='tg-show-flow-state',
|
||||||
description=__doc__,
|
description=__doc__,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-f', '--flow-id',
|
||||||
|
default="0000",
|
||||||
|
help=f'Flow ID (default: 0000)'
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-m', '--metrics-url',
|
'-m', '--metrics-url',
|
||||||
default=default_metrics_url,
|
default=default_metrics_url,
|
||||||
|
|
@ -45,7 +58,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
dump_status(args.metrics_url)
|
dump_status(args.metrics_url, args.flow_id)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
|
@ -44,8 +44,8 @@ setuptools.setup(
|
||||||
"websockets",
|
"websockets",
|
||||||
],
|
],
|
||||||
scripts=[
|
scripts=[
|
||||||
"scripts/tg-dump-msgpack",
|
|
||||||
"scripts/tg-delete-flow-class",
|
"scripts/tg-delete-flow-class",
|
||||||
|
"scripts/tg-dump-msgpack",
|
||||||
"scripts/tg-get-flow-class",
|
"scripts/tg-get-flow-class",
|
||||||
"scripts/tg-graph-show",
|
"scripts/tg-graph-show",
|
||||||
"scripts/tg-graph-to-turtle",
|
"scripts/tg-graph-to-turtle",
|
||||||
|
|
@ -61,7 +61,6 @@ setuptools.setup(
|
||||||
"scripts/tg-load-pdf",
|
"scripts/tg-load-pdf",
|
||||||
"scripts/tg-load-text",
|
"scripts/tg-load-text",
|
||||||
"scripts/tg-load-turtle",
|
"scripts/tg-load-turtle",
|
||||||
"scripts/tg-processor-state",
|
|
||||||
"scripts/tg-put-flow-class",
|
"scripts/tg-put-flow-class",
|
||||||
"scripts/tg-save-doc-embeds",
|
"scripts/tg-save-doc-embeds",
|
||||||
"scripts/tg-save-kg-core",
|
"scripts/tg-save-kg-core",
|
||||||
|
|
@ -69,7 +68,9 @@ setuptools.setup(
|
||||||
"scripts/tg-set-token-costs",
|
"scripts/tg-set-token-costs",
|
||||||
"scripts/tg-show-config",
|
"scripts/tg-show-config",
|
||||||
"scripts/tg-show-flow-classes",
|
"scripts/tg-show-flow-classes",
|
||||||
|
"scripts/tg-show-flow-state",
|
||||||
"scripts/tg-show-flows",
|
"scripts/tg-show-flows",
|
||||||
|
"scripts/tg-show-processor-state",
|
||||||
"scripts/tg-show-prompts",
|
"scripts/tg-show-prompts",
|
||||||
"scripts/tg-show-token-costs",
|
"scripts/tg-show-token-costs",
|
||||||
"scripts/tg-show-tools",
|
"scripts/tg-show-tools",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue