Python API implements streaming interfaces (#577)

* 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
This commit is contained in:
cybermaggedon 2025-12-04 17:38:57 +00:00 committed by GitHub
parent b957004db9
commit 01aeede78b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 4489 additions and 715 deletions

View file

@ -13,6 +13,7 @@ from trustgraph.api.types import hash, Uri, Literal, Triple
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
default_user = 'trustgraph'
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
from requests.adapters import HTTPAdapter
@ -655,10 +656,10 @@ documents = [
class Loader:
def __init__(
self, url, user
self, url, user, token=None
):
self.api = Api(url).library()
self.api = Api(url, token=token).library()
self.user = user
def load(self, documents):
@ -719,6 +720,12 @@ def main():
help=f'User ID (default: {default_user})'
)
parser.add_argument(
'-t', '--token',
default=default_token,
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
)
args = parser.parse_args()
try:
@ -726,6 +733,7 @@ def main():
p = Loader(
url=args.url,
user=args.user,
token=args.token,
)
p.load(documents)