mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
Collection management part 2 (#522)
* Plumb collection manager into librarian * Test end-to-end
This commit is contained in:
parent
d378db9370
commit
fcd15d1833
16 changed files with 617 additions and 434 deletions
|
|
@ -17,8 +17,9 @@ def list_collections(url, user, tag_filter):
|
|||
|
||||
collections = api.list_collections(user=user, tag_filter=tag_filter)
|
||||
|
||||
if len(collections) == 0:
|
||||
print("No collections.")
|
||||
# Handle None or empty collections
|
||||
if not collections or len(collections) == 0:
|
||||
print("No collections found.")
|
||||
return
|
||||
|
||||
table = []
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Update collection metadata
|
||||
Set collection metadata (creates if doesn't exist)
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
|
@ -10,7 +10,7 @@ from trustgraph.api import Api
|
|||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_user = "trustgraph"
|
||||
|
||||
def update_collection(url, user, collection, name, description, tags):
|
||||
def set_collection(url, user, collection, name, description, tags):
|
||||
|
||||
api = Api(url).collection()
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ def update_collection(url, user, collection, name, description, tags):
|
|||
)
|
||||
|
||||
if result:
|
||||
print(f"Collection '{collection}' updated successfully.")
|
||||
print(f"Collection '{collection}' set successfully.")
|
||||
|
||||
table = []
|
||||
table.append(("Collection", result.collection))
|
||||
|
|
@ -39,18 +39,18 @@ def update_collection(url, user, collection, name, description, tags):
|
|||
maxcolwidths=[None, 67],
|
||||
))
|
||||
else:
|
||||
print(f"Failed to update collection '{collection}'.")
|
||||
print(f"Failed to set collection '{collection}'.")
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='tg-update-collection',
|
||||
prog='tg-set-collection',
|
||||
description=__doc__,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'collection',
|
||||
help='Collection ID to update'
|
||||
help='Collection ID to set'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
|
@ -86,7 +86,7 @@ def main():
|
|||
|
||||
try:
|
||||
|
||||
update_collection(
|
||||
set_collection(
|
||||
url = args.api_url,
|
||||
user = args.user,
|
||||
collection = args.collection,
|
||||
Loading…
Add table
Add a link
Reference in a new issue