trustgraph-cli 0.11.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trustgraph-cli-0.11.13/PKG-INFO +19 -0
- trustgraph-cli-0.11.13/README.md +1 -0
- trustgraph-cli-0.11.13/scripts/tg-graph-show +46 -0
- trustgraph-cli-0.11.13/scripts/tg-graph-to-turtle +74 -0
- trustgraph-cli-0.11.13/scripts/tg-init-pulsar +119 -0
- trustgraph-cli-0.11.13/scripts/tg-init-pulsar-manager +11 -0
- trustgraph-cli-0.11.13/scripts/tg-load-pdf +128 -0
- trustgraph-cli-0.11.13/scripts/tg-load-text +128 -0
- trustgraph-cli-0.11.13/scripts/tg-processor-state +24 -0
- trustgraph-cli-0.11.13/scripts/tg-query-document-rag +49 -0
- trustgraph-cli-0.11.13/scripts/tg-query-graph-rag +49 -0
- trustgraph-cli-0.11.13/setup.cfg +4 -0
- trustgraph-cli-0.11.13/setup.py +53 -0
- trustgraph-cli-0.11.13/trustgraph/cli_version.py +1 -0
- trustgraph-cli-0.11.13/trustgraph/utils_version.py +1 -0
- trustgraph-cli-0.11.13/trustgraph_cli.egg-info/PKG-INFO +19 -0
- trustgraph-cli-0.11.13/trustgraph_cli.egg-info/SOURCES.txt +18 -0
- trustgraph-cli-0.11.13/trustgraph_cli.egg-info/dependency_links.txt +1 -0
- trustgraph-cli-0.11.13/trustgraph_cli.egg-info/requires.txt +4 -0
- trustgraph-cli-0.11.13/trustgraph_cli.egg-info/top_level.txt +3 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: trustgraph-cli
|
|
3
|
+
Version: 0.11.13
|
|
4
|
+
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
|
+
Home-page: https://github.com/trustgraph-ai/trustgraph
|
|
6
|
+
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.11.13.tar.gz
|
|
7
|
+
Author: trustgraph.ai
|
|
8
|
+
Author-email: security@trustgraph.ai
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: trustgraph-base
|
|
15
|
+
Requires-Dist: requests
|
|
16
|
+
Requires-Dist: pulsar-client
|
|
17
|
+
Requires-Dist: tabulate
|
|
18
|
+
|
|
19
|
+
See https://trustgraph.ai/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
See https://trustgraph.ai/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Connects to the graph query service and dumps all graph edges.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from trustgraph.clients.triples_query_client import TriplesQueryClient
|
|
10
|
+
|
|
11
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
12
|
+
|
|
13
|
+
def show_graph(pulsar):
|
|
14
|
+
|
|
15
|
+
tq = TriplesQueryClient(pulsar_host=pulsar)
|
|
16
|
+
|
|
17
|
+
rows = tq.request(None, None, None, limit=10_000_000)
|
|
18
|
+
|
|
19
|
+
for row in rows:
|
|
20
|
+
print(row.s.value, row.p.value, row.o.value)
|
|
21
|
+
|
|
22
|
+
def main():
|
|
23
|
+
|
|
24
|
+
parser = argparse.ArgumentParser(
|
|
25
|
+
prog='graph-show',
|
|
26
|
+
description=__doc__,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
'-p', '--pulsar-host',
|
|
31
|
+
default=default_pulsar_host,
|
|
32
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
|
|
39
|
+
show_graph(args.pulsar_host)
|
|
40
|
+
|
|
41
|
+
except Exception as e:
|
|
42
|
+
|
|
43
|
+
print("Exception:", e, flush=True)
|
|
44
|
+
|
|
45
|
+
main()
|
|
46
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Connects to the graph query service and dumps all graph edges.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from trustgraph.clients.triples_query_client import TriplesQueryClient
|
|
10
|
+
import rdflib
|
|
11
|
+
import io
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
15
|
+
|
|
16
|
+
def show_graph(pulsar):
|
|
17
|
+
|
|
18
|
+
tq = TriplesQueryClient(pulsar_host=pulsar)
|
|
19
|
+
|
|
20
|
+
rows = tq.request(None, None, None, limit=10_000_000)
|
|
21
|
+
|
|
22
|
+
g = rdflib.Graph()
|
|
23
|
+
|
|
24
|
+
for row in rows:
|
|
25
|
+
|
|
26
|
+
sv = rdflib.term.URIRef(row.s.value)
|
|
27
|
+
pv = rdflib.term.URIRef(row.p.value)
|
|
28
|
+
|
|
29
|
+
if row.o.is_uri:
|
|
30
|
+
|
|
31
|
+
# Skip malformed URLs with spaces in
|
|
32
|
+
if " " in row.o.value:
|
|
33
|
+
continue
|
|
34
|
+
|
|
35
|
+
ov = rdflib.term.URIRef(row.o.value)
|
|
36
|
+
else:
|
|
37
|
+
ov = rdflib.term.Literal(row.o.value)
|
|
38
|
+
|
|
39
|
+
g.add((sv, pv, ov))
|
|
40
|
+
|
|
41
|
+
g.serialize(destination="output.ttl", format="turtle")
|
|
42
|
+
|
|
43
|
+
buf = io.BytesIO()
|
|
44
|
+
|
|
45
|
+
g.serialize(destination=buf, format="turtle")
|
|
46
|
+
|
|
47
|
+
sys.stdout.write(buf.getvalue().decode("utf-8"))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def main():
|
|
51
|
+
|
|
52
|
+
parser = argparse.ArgumentParser(
|
|
53
|
+
prog='graph-show',
|
|
54
|
+
description=__doc__,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
'-p', '--pulsar-host',
|
|
59
|
+
default=default_pulsar_host,
|
|
60
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
args = parser.parse_args()
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
|
|
67
|
+
show_graph(args.pulsar_host)
|
|
68
|
+
|
|
69
|
+
except Exception as e:
|
|
70
|
+
|
|
71
|
+
print("Exception:", e, flush=True)
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Initialises Pulsar with Trustgraph tenant / namespaces & policy
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
import time
|
|
9
|
+
import argparse
|
|
10
|
+
|
|
11
|
+
default_pulsar_admin_url = "http://pulsar:8080"
|
|
12
|
+
|
|
13
|
+
def get_clusters(url):
|
|
14
|
+
|
|
15
|
+
print("Get clusters...", flush=True)
|
|
16
|
+
|
|
17
|
+
resp = requests.get(f"{url}/admin/v2/clusters")
|
|
18
|
+
|
|
19
|
+
if resp.status_code != 200: raise RuntimeError("Could not fetch clusters")
|
|
20
|
+
|
|
21
|
+
return resp.json()
|
|
22
|
+
|
|
23
|
+
def ensure_tenant(url, tenant, clusters):
|
|
24
|
+
|
|
25
|
+
resp = requests.get(f"{url}/admin/v2/tenants/{tenant}")
|
|
26
|
+
|
|
27
|
+
if resp.status_code == 200:
|
|
28
|
+
print(f"Tenant {tenant} already exists.", flush=True)
|
|
29
|
+
return
|
|
30
|
+
|
|
31
|
+
resp = requests.put(
|
|
32
|
+
f"{url}/admin/v2/tenants/{tenant}",
|
|
33
|
+
json={
|
|
34
|
+
"adminRoles": [],
|
|
35
|
+
"allowedClusters": clusters,
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if resp.status_code != 204:
|
|
40
|
+
print(resp.text, flush=True)
|
|
41
|
+
raise RuntimeError("Tenant creation failed.")
|
|
42
|
+
|
|
43
|
+
print(f"Tenant {tenant} created.", flush=True)
|
|
44
|
+
|
|
45
|
+
def ensure_namespace(url, tenant, namespace, config):
|
|
46
|
+
|
|
47
|
+
resp = requests.get(f"{url}/admin/v2/namespaces/{tenant}/{namespace}")
|
|
48
|
+
|
|
49
|
+
if resp.status_code == 200:
|
|
50
|
+
print(f"Namespace {tenant}/{namespace} already exists.", flush=True)
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
resp = requests.put(
|
|
54
|
+
f"{url}/admin/v2/namespaces/{tenant}/{namespace}",
|
|
55
|
+
json=config,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if resp.status_code != 204:
|
|
59
|
+
print(resp.status_code, flush=True)
|
|
60
|
+
print(resp.text, flush=True)
|
|
61
|
+
raise RuntimeError(f"Namespace {tenant}/{namespace} creation failed.")
|
|
62
|
+
|
|
63
|
+
print(f"Namespace {tenant}/{namespace} created.", flush=True)
|
|
64
|
+
|
|
65
|
+
def init(url, tenant="tg"):
|
|
66
|
+
|
|
67
|
+
clusters = get_clusters(url)
|
|
68
|
+
|
|
69
|
+
ensure_tenant(url, tenant, clusters)
|
|
70
|
+
|
|
71
|
+
ensure_namespace(url, tenant, "flow", {})
|
|
72
|
+
|
|
73
|
+
ensure_namespace(url, tenant, "request", {})
|
|
74
|
+
|
|
75
|
+
ensure_namespace(url, tenant, "response", {
|
|
76
|
+
"retention_policies": {
|
|
77
|
+
"retentionSizeInMB": -1,
|
|
78
|
+
"retentionTimeInMinutes": 3,
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
def main():
|
|
83
|
+
|
|
84
|
+
parser = argparse.ArgumentParser(
|
|
85
|
+
prog='tg-init-pulsar',
|
|
86
|
+
description=__doc__,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
parser.add_argument(
|
|
90
|
+
'-p', '--pulsar-admin-url',
|
|
91
|
+
default=default_pulsar_admin_url,
|
|
92
|
+
help=f'Pulsar admin URL (default: {default_pulsar_admin_url})',
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
args = parser.parse_args()
|
|
96
|
+
|
|
97
|
+
while True:
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
|
|
101
|
+
print(flush=True)
|
|
102
|
+
print(
|
|
103
|
+
f"Initialising with Pulsar {args.pulsar_admin_url}...",
|
|
104
|
+
flush=True
|
|
105
|
+
)
|
|
106
|
+
init(args.pulsar_admin_url, "tg")
|
|
107
|
+
print("Initialisation complete.", flush=True)
|
|
108
|
+
break
|
|
109
|
+
|
|
110
|
+
except Exception as e:
|
|
111
|
+
|
|
112
|
+
print("Exception:", e, flush=True)
|
|
113
|
+
|
|
114
|
+
print("Sleeping...", flush=True)
|
|
115
|
+
time.sleep(2)
|
|
116
|
+
print("Will retry...", flush=True)
|
|
117
|
+
|
|
118
|
+
main()
|
|
119
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
CSRF_TOKEN=$(curl http://localhost:7750/pulsar-manager/csrf-token)
|
|
4
|
+
|
|
5
|
+
curl \
|
|
6
|
+
-H "X-XSRF-TOKEN: $CSRF_TOKEN" \
|
|
7
|
+
-H "Cookie: XSRF-TOKEN=$CSRF_TOKEN;" \
|
|
8
|
+
-H 'Content-Type: application/json' \
|
|
9
|
+
-X PUT \
|
|
10
|
+
http://localhost:7750/pulsar-manager/users/superuser \
|
|
11
|
+
-d '{"name": "admin", "password": "apachepulsar", "description": "test", "email": "username@test.org"}'
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Loads a PDF document into TrustGraph processing.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pulsar
|
|
8
|
+
from pulsar.schema import JsonSchema
|
|
9
|
+
from trustgraph.schema import Document, Source, document_ingest_queue
|
|
10
|
+
import base64
|
|
11
|
+
import hashlib
|
|
12
|
+
import argparse
|
|
13
|
+
import os
|
|
14
|
+
import time
|
|
15
|
+
|
|
16
|
+
from trustgraph.log_level import LogLevel
|
|
17
|
+
|
|
18
|
+
class Loader:
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
pulsar_host,
|
|
23
|
+
output_queue,
|
|
24
|
+
log_level,
|
|
25
|
+
file,
|
|
26
|
+
):
|
|
27
|
+
|
|
28
|
+
self.client = pulsar.Client(
|
|
29
|
+
pulsar_host,
|
|
30
|
+
logger=pulsar.ConsoleLogger(log_level.to_pulsar())
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
self.producer = self.client.create_producer(
|
|
34
|
+
topic=output_queue,
|
|
35
|
+
schema=JsonSchema(Document),
|
|
36
|
+
chunking_enabled=True,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
self.file = file
|
|
40
|
+
|
|
41
|
+
def run(self):
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
|
|
45
|
+
path = self.file
|
|
46
|
+
data = open(path, "rb").read()
|
|
47
|
+
|
|
48
|
+
id = hashlib.sha256(path.encode("utf-8")).hexdigest()[0:8]
|
|
49
|
+
|
|
50
|
+
r = Document(
|
|
51
|
+
source=Source(
|
|
52
|
+
source=path,
|
|
53
|
+
title=path,
|
|
54
|
+
id=id,
|
|
55
|
+
),
|
|
56
|
+
data=base64.b64encode(data),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
self.producer.send(r)
|
|
60
|
+
|
|
61
|
+
except Exception as e:
|
|
62
|
+
print(e, flush=True)
|
|
63
|
+
|
|
64
|
+
def __del__(self):
|
|
65
|
+
self.client.close()
|
|
66
|
+
|
|
67
|
+
def main():
|
|
68
|
+
|
|
69
|
+
parser = argparse.ArgumentParser(
|
|
70
|
+
prog='loader',
|
|
71
|
+
description=__doc__,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
75
|
+
default_output_queue = document_ingest_queue
|
|
76
|
+
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
'-p', '--pulsar-host',
|
|
79
|
+
default=default_pulsar_host,
|
|
80
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
parser.add_argument(
|
|
84
|
+
'-o', '--output-queue',
|
|
85
|
+
default=default_output_queue,
|
|
86
|
+
help=f'Output queue (default: {default_output_queue})'
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
parser.add_argument(
|
|
90
|
+
'-l', '--log-level',
|
|
91
|
+
type=LogLevel,
|
|
92
|
+
default=LogLevel.ERROR,
|
|
93
|
+
choices=list(LogLevel),
|
|
94
|
+
help=f'Output queue (default: info)'
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
parser.add_argument(
|
|
98
|
+
'-f', '--file',
|
|
99
|
+
required=True,
|
|
100
|
+
help=f'File to load'
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
args = parser.parse_args()
|
|
104
|
+
|
|
105
|
+
while True:
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
p = Loader(
|
|
109
|
+
pulsar_host=args.pulsar_host,
|
|
110
|
+
output_queue=args.output_queue,
|
|
111
|
+
log_level=args.log_level,
|
|
112
|
+
file=args.file,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
p.run()
|
|
116
|
+
|
|
117
|
+
print("File loaded.")
|
|
118
|
+
break
|
|
119
|
+
|
|
120
|
+
except Exception as e:
|
|
121
|
+
|
|
122
|
+
print("Exception:", e, flush=True)
|
|
123
|
+
print("Will retry...", flush=True)
|
|
124
|
+
|
|
125
|
+
time.sleep(10)
|
|
126
|
+
|
|
127
|
+
main()
|
|
128
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Loads a text document into TrustGraph processing.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pulsar
|
|
8
|
+
from pulsar.schema import JsonSchema
|
|
9
|
+
from trustgraph.schema import TextDocument, Source, text_ingest_queue
|
|
10
|
+
import base64
|
|
11
|
+
import hashlib
|
|
12
|
+
import argparse
|
|
13
|
+
import os
|
|
14
|
+
import time
|
|
15
|
+
|
|
16
|
+
from trustgraph.log_level import LogLevel
|
|
17
|
+
|
|
18
|
+
class Loader:
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
pulsar_host,
|
|
23
|
+
output_queue,
|
|
24
|
+
log_level,
|
|
25
|
+
file,
|
|
26
|
+
):
|
|
27
|
+
|
|
28
|
+
self.client = pulsar.Client(
|
|
29
|
+
pulsar_host,
|
|
30
|
+
logger=pulsar.ConsoleLogger(log_level.to_pulsar())
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
self.producer = self.client.create_producer(
|
|
34
|
+
topic=output_queue,
|
|
35
|
+
schema=JsonSchema(TextDocument),
|
|
36
|
+
chunking_enabled=True,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
self.file = file
|
|
40
|
+
|
|
41
|
+
def run(self):
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
|
|
45
|
+
path = self.file
|
|
46
|
+
data = open(path, "rb").read()
|
|
47
|
+
|
|
48
|
+
id = hashlib.sha256(path.encode("utf-8")).hexdigest()[0:8]
|
|
49
|
+
|
|
50
|
+
r = TextDocument(
|
|
51
|
+
source=Source(
|
|
52
|
+
source=path,
|
|
53
|
+
title=path,
|
|
54
|
+
id=id,
|
|
55
|
+
),
|
|
56
|
+
text=data,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
self.producer.send(r)
|
|
60
|
+
|
|
61
|
+
except Exception as e:
|
|
62
|
+
print(e, flush=True)
|
|
63
|
+
|
|
64
|
+
def __del__(self):
|
|
65
|
+
self.client.close()
|
|
66
|
+
|
|
67
|
+
def main():
|
|
68
|
+
|
|
69
|
+
parser = argparse.ArgumentParser(
|
|
70
|
+
prog='loader',
|
|
71
|
+
description=__doc__,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
75
|
+
default_output_queue = text_ingest_queue
|
|
76
|
+
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
'-p', '--pulsar-host',
|
|
79
|
+
default=default_pulsar_host,
|
|
80
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
parser.add_argument(
|
|
84
|
+
'-o', '--output-queue',
|
|
85
|
+
default=default_output_queue,
|
|
86
|
+
help=f'Output queue (default: {default_output_queue})'
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
parser.add_argument(
|
|
90
|
+
'-l', '--log-level',
|
|
91
|
+
type=LogLevel,
|
|
92
|
+
default=LogLevel.ERROR,
|
|
93
|
+
choices=list(LogLevel),
|
|
94
|
+
help=f'Output queue (default: info)'
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
parser.add_argument(
|
|
98
|
+
'-f', '--file',
|
|
99
|
+
required=True,
|
|
100
|
+
help=f'File to load'
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
args = parser.parse_args()
|
|
104
|
+
|
|
105
|
+
while True:
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
p = Loader(
|
|
109
|
+
pulsar_host=args.pulsar_host,
|
|
110
|
+
output_queue=args.output_queue,
|
|
111
|
+
log_level=args.log_level,
|
|
112
|
+
file=args.file,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
p.run()
|
|
116
|
+
|
|
117
|
+
print("File loaded.")
|
|
118
|
+
break
|
|
119
|
+
|
|
120
|
+
except Exception as e:
|
|
121
|
+
|
|
122
|
+
print("Exception:", e, flush=True)
|
|
123
|
+
print("Will retry...", flush=True)
|
|
124
|
+
|
|
125
|
+
time.sleep(10)
|
|
126
|
+
|
|
127
|
+
main()
|
|
128
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
import tabulate
|
|
5
|
+
|
|
6
|
+
url = 'http://localhost:9090/api/v1/query?query=processor_state%7Bprocessor_state%3D%22running%22%7D'
|
|
7
|
+
|
|
8
|
+
resp = requests.get(url)
|
|
9
|
+
|
|
10
|
+
obj = resp.json()
|
|
11
|
+
|
|
12
|
+
tbl = [
|
|
13
|
+
[
|
|
14
|
+
m["metric"]["job"],
|
|
15
|
+
"running" if int(m["value"][1]) > 0 else "down"
|
|
16
|
+
]
|
|
17
|
+
for m in obj["data"]["result"]
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
print(tabulate.tabulate(
|
|
21
|
+
tbl, tablefmt="pretty", headers=["processor", "state"],
|
|
22
|
+
stralign="left"
|
|
23
|
+
))
|
|
24
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Uses the Document RAG service to answer a query
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from trustgraph.clients.document_rag_client import DocumentRagClient
|
|
10
|
+
|
|
11
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
12
|
+
|
|
13
|
+
def query(pulsar, query):
|
|
14
|
+
|
|
15
|
+
rag = DocumentRagClient(pulsar_host=pulsar)
|
|
16
|
+
resp = rag.request(query)
|
|
17
|
+
print(resp)
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
|
|
21
|
+
parser = argparse.ArgumentParser(
|
|
22
|
+
prog='graph-show',
|
|
23
|
+
description=__doc__,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
'-p', '--pulsar-host',
|
|
28
|
+
default=default_pulsar_host,
|
|
29
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
'-q', '--query',
|
|
34
|
+
required=True,
|
|
35
|
+
help=f'Query to execute',
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
args = parser.parse_args()
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
|
|
42
|
+
query(args.pulsar_host, args.query)
|
|
43
|
+
|
|
44
|
+
except Exception as e:
|
|
45
|
+
|
|
46
|
+
print("Exception:", e, flush=True)
|
|
47
|
+
|
|
48
|
+
main()
|
|
49
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Uses the GraphRAG service to answer a query
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from trustgraph.clients.graph_rag_client import GraphRagClient
|
|
10
|
+
|
|
11
|
+
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
12
|
+
|
|
13
|
+
def query(pulsar, query):
|
|
14
|
+
|
|
15
|
+
rag = GraphRagClient(pulsar_host=pulsar)
|
|
16
|
+
resp = rag.request(query)
|
|
17
|
+
print(resp)
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
|
|
21
|
+
parser = argparse.ArgumentParser(
|
|
22
|
+
prog='graph-show',
|
|
23
|
+
description=__doc__,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
'-p', '--pulsar-host',
|
|
28
|
+
default=default_pulsar_host,
|
|
29
|
+
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
'-q', '--query',
|
|
34
|
+
required=True,
|
|
35
|
+
help=f'Query to execute',
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
args = parser.parse_args()
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
|
|
42
|
+
query(args.pulsar_host, args.query)
|
|
43
|
+
|
|
44
|
+
except Exception as e:
|
|
45
|
+
|
|
46
|
+
print("Exception:", e, flush=True)
|
|
47
|
+
|
|
48
|
+
main()
|
|
49
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
import os
|
|
3
|
+
import importlib
|
|
4
|
+
|
|
5
|
+
with open("README.md", "r") as fh:
|
|
6
|
+
long_description = fh.read()
|
|
7
|
+
|
|
8
|
+
# Load a version number module
|
|
9
|
+
spec = importlib.util.spec_from_file_location(
|
|
10
|
+
'version', 'trustgraph/cli_version.py'
|
|
11
|
+
)
|
|
12
|
+
version_module = importlib.util.module_from_spec(spec)
|
|
13
|
+
spec.loader.exec_module(version_module)
|
|
14
|
+
|
|
15
|
+
version = version_module.__version__
|
|
16
|
+
|
|
17
|
+
setuptools.setup(
|
|
18
|
+
name="trustgraph-cli",
|
|
19
|
+
version=version,
|
|
20
|
+
author="trustgraph.ai",
|
|
21
|
+
author_email="security@trustgraph.ai",
|
|
22
|
+
description="TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.",
|
|
23
|
+
long_description=long_description,
|
|
24
|
+
long_description_content_type="text/markdown",
|
|
25
|
+
url="https://github.com/trustgraph-ai/trustgraph",
|
|
26
|
+
packages=setuptools.find_namespace_packages(
|
|
27
|
+
where='./',
|
|
28
|
+
),
|
|
29
|
+
classifiers=[
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
],
|
|
34
|
+
python_requires='>=3.8',
|
|
35
|
+
download_url = "https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v" + version + ".tar.gz",
|
|
36
|
+
install_requires=[
|
|
37
|
+
"trustgraph-base",
|
|
38
|
+
"requests",
|
|
39
|
+
"pulsar-client",
|
|
40
|
+
"tabulate",
|
|
41
|
+
],
|
|
42
|
+
scripts=[
|
|
43
|
+
"scripts/tg-graph-show",
|
|
44
|
+
"scripts/tg-graph-to-turtle",
|
|
45
|
+
"scripts/tg-init-pulsar-manager",
|
|
46
|
+
"scripts/tg-load-pdf",
|
|
47
|
+
"scripts/tg-load-text",
|
|
48
|
+
"scripts/tg-query-document-rag",
|
|
49
|
+
"scripts/tg-query-graph-rag",
|
|
50
|
+
"scripts/tg-init-pulsar",
|
|
51
|
+
"scripts/tg-processor-state",
|
|
52
|
+
]
|
|
53
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.11.13"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.11.12"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: trustgraph-cli
|
|
3
|
+
Version: 0.11.13
|
|
4
|
+
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
|
+
Home-page: https://github.com/trustgraph-ai/trustgraph
|
|
6
|
+
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.11.13.tar.gz
|
|
7
|
+
Author: trustgraph.ai
|
|
8
|
+
Author-email: security@trustgraph.ai
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: trustgraph-base
|
|
15
|
+
Requires-Dist: requests
|
|
16
|
+
Requires-Dist: pulsar-client
|
|
17
|
+
Requires-Dist: tabulate
|
|
18
|
+
|
|
19
|
+
See https://trustgraph.ai/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
scripts/tg-graph-show
|
|
4
|
+
scripts/tg-graph-to-turtle
|
|
5
|
+
scripts/tg-init-pulsar
|
|
6
|
+
scripts/tg-init-pulsar-manager
|
|
7
|
+
scripts/tg-load-pdf
|
|
8
|
+
scripts/tg-load-text
|
|
9
|
+
scripts/tg-processor-state
|
|
10
|
+
scripts/tg-query-document-rag
|
|
11
|
+
scripts/tg-query-graph-rag
|
|
12
|
+
trustgraph/cli_version.py
|
|
13
|
+
trustgraph/utils_version.py
|
|
14
|
+
trustgraph_cli.egg-info/PKG-INFO
|
|
15
|
+
trustgraph_cli.egg-info/SOURCES.txt
|
|
16
|
+
trustgraph_cli.egg-info/dependency_links.txt
|
|
17
|
+
trustgraph_cli.egg-info/requires.txt
|
|
18
|
+
trustgraph_cli.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|