mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
* Update schema defs for source -> metadata * Migrate to use metadata part of schema, also add metadata to triples & vecs * Add user/collection metadata to query * Use user/collection in RAG * Write and query working on triples
66 lines
1.4 KiB
Python
Executable file
66 lines
1.4 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Connects to the graph query service and dumps all graph edges.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
from trustgraph.clients.triples_query_client import TriplesQueryClient
|
|
|
|
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
|
default_user = 'trustgraph'
|
|
default_collection = 'default'
|
|
|
|
def show_graph(pulsar, user, collection):
|
|
|
|
tq = TriplesQueryClient(pulsar_host=pulsar)
|
|
|
|
rows = tq.request(
|
|
user=user, collection=collection,
|
|
s=None, p=None, o=None, limit=10_000_000
|
|
)
|
|
|
|
for row in rows:
|
|
print(row.s.value, row.p.value, row.o.value)
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog='graph-show',
|
|
description=__doc__,
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-p', '--pulsar-host',
|
|
default=default_pulsar_host,
|
|
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-u', '--user',
|
|
default=default_user,
|
|
help=f'User ID (default: {default_user})'
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-c', '--collection',
|
|
default=default_collection,
|
|
help=f'Collection ID (default: {default_collection})'
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
|
|
show_graph(
|
|
pulsar=args.pulsar_host, user=args.user,
|
|
collection=args.collection,
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
print("Exception:", e, flush=True)
|
|
|
|
main()
|
|
|