mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 04:31:02 +02:00
Remove cruft
This commit is contained in:
parent
c06918a677
commit
d5a84ae9e3
3 changed files with 16 additions and 52 deletions
|
|
@ -37,7 +37,6 @@ class Librarian:
|
||||||
"Invalid document kind: " + request.document_metadata.kind
|
"Invalid document kind: " + request.document_metadata.kind
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Existence test...")
|
|
||||||
if await self.table_store.document_exists(
|
if await self.table_store.document_exists(
|
||||||
request.document_metadata.user,
|
request.document_metadata.user,
|
||||||
request.document_metadata.id
|
request.document_metadata.id
|
||||||
|
|
@ -47,11 +46,6 @@ class Librarian:
|
||||||
# Create object ID for blob
|
# Create object ID for blob
|
||||||
object_id = uuid.uuid4()
|
object_id = uuid.uuid4()
|
||||||
|
|
||||||
print("OID", object_id)
|
|
||||||
print(request.content)
|
|
||||||
print("CONT", base64.b64decode(request.content))
|
|
||||||
|
|
||||||
|
|
||||||
print("Add blob...")
|
print("Add blob...")
|
||||||
|
|
||||||
await self.blob_store.add(
|
await self.blob_store.add(
|
||||||
|
|
@ -77,7 +71,7 @@ class Librarian:
|
||||||
|
|
||||||
async def remove_document(self, request):
|
async def remove_document(self, request):
|
||||||
|
|
||||||
print("REMOVING...")
|
print("Removing doc...")
|
||||||
|
|
||||||
if not await self.table_store.document_exists(
|
if not await self.table_store.document_exists(
|
||||||
request.user,
|
request.user,
|
||||||
|
|
@ -111,7 +105,7 @@ class Librarian:
|
||||||
|
|
||||||
async def update_document(self, request):
|
async def update_document(self, request):
|
||||||
|
|
||||||
print("UPDATING...")
|
print("Updating doc...")
|
||||||
|
|
||||||
# You can't update the document ID, user or kind.
|
# You can't update the document ID, user or kind.
|
||||||
|
|
||||||
|
|
@ -135,7 +129,7 @@ class Librarian:
|
||||||
|
|
||||||
async def get_document_metadata(self, request):
|
async def get_document_metadata(self, request):
|
||||||
|
|
||||||
print("GET DOC...")
|
print("Get doc...")
|
||||||
|
|
||||||
doc = await self.table_store.get_document(
|
doc = await self.table_store.get_document(
|
||||||
request.user,
|
request.user,
|
||||||
|
|
@ -154,15 +148,13 @@ class Librarian:
|
||||||
|
|
||||||
async def get_document_content(self, request):
|
async def get_document_content(self, request):
|
||||||
|
|
||||||
print("GET DOC CONTENT...")
|
print("Get doc content...")
|
||||||
|
|
||||||
object_id = await self.table_store.get_document_object_id(
|
object_id = await self.table_store.get_document_object_id(
|
||||||
request.user,
|
request.user,
|
||||||
request.document_id
|
request.document_id
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Now", object_id)
|
|
||||||
|
|
||||||
content = await self.blob_store.get(
|
content = await self.blob_store.get(
|
||||||
object_id
|
object_id
|
||||||
)
|
)
|
||||||
|
|
@ -179,31 +171,24 @@ class Librarian:
|
||||||
|
|
||||||
async def add_processing(self, request):
|
async def add_processing(self, request):
|
||||||
|
|
||||||
print("LIST PROCESSING")
|
print("Add processing")
|
||||||
|
|
||||||
print("Existence test...")
|
|
||||||
if await self.table_store.processing_exists(
|
if await self.table_store.processing_exists(
|
||||||
request.processing_metadata.user,
|
request.processing_metadata.user,
|
||||||
request.processing_metadata.id
|
request.processing_metadata.id
|
||||||
):
|
):
|
||||||
raise RuntimeError("Processing already exists")
|
raise RuntimeError("Processing already exists")
|
||||||
|
|
||||||
print("Does not already exist")
|
|
||||||
|
|
||||||
doc = await self.table_store.get_document(
|
doc = await self.table_store.get_document(
|
||||||
request.processing_metadata.user,
|
request.processing_metadata.user,
|
||||||
request.processing_metadata.document_id
|
request.processing_metadata.document_id
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Got doc")
|
|
||||||
|
|
||||||
object_id = await self.table_store.get_document_object_id(
|
object_id = await self.table_store.get_document_object_id(
|
||||||
request.processing_metadata.user,
|
request.processing_metadata.user,
|
||||||
request.processing_metadata.document_id
|
request.processing_metadata.document_id
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Got object ID")
|
|
||||||
|
|
||||||
content = await self.blob_store.get(
|
content = await self.blob_store.get(
|
||||||
object_id
|
object_id
|
||||||
)
|
)
|
||||||
|
|
@ -232,7 +217,7 @@ class Librarian:
|
||||||
|
|
||||||
async def remove_processing(self, request):
|
async def remove_processing(self, request):
|
||||||
|
|
||||||
print("REMOVING...")
|
print("Removing processing...")
|
||||||
|
|
||||||
if not await self.table_store.processing_exists(
|
if not await self.table_store.processing_exists(
|
||||||
request.user,
|
request.user,
|
||||||
|
|
@ -260,8 +245,6 @@ class Librarian:
|
||||||
|
|
||||||
docs = await self.table_store.list_documents(request.user)
|
docs = await self.table_store.list_documents(request.user)
|
||||||
|
|
||||||
print(docs)
|
|
||||||
|
|
||||||
return LibrarianResponse(
|
return LibrarianResponse(
|
||||||
error = None,
|
error = None,
|
||||||
document_metadata = None,
|
document_metadata = None,
|
||||||
|
|
@ -272,12 +255,8 @@ class Librarian:
|
||||||
|
|
||||||
async def list_processing(self, request):
|
async def list_processing(self, request):
|
||||||
|
|
||||||
print("LIST PROCESSING")
|
|
||||||
|
|
||||||
procs = await self.table_store.list_processing(request.user)
|
procs = await self.table_store.list_processing(request.user)
|
||||||
|
|
||||||
print(procs)
|
|
||||||
|
|
||||||
return LibrarianResponse(
|
return LibrarianResponse(
|
||||||
error = None,
|
error = None,
|
||||||
document_metadata = None,
|
document_metadata = None,
|
||||||
|
|
|
||||||
|
|
@ -144,15 +144,9 @@ class Processor(AsyncProcessor):
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
# self.running = False
|
|
||||||
|
|
||||||
async def load_document(self, document):
|
async def load_document(self, document):
|
||||||
|
|
||||||
print(document)
|
|
||||||
print(document.flow)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
doc = Document(
|
doc = Document(
|
||||||
metadata = Metadata(
|
metadata = Metadata(
|
||||||
id = document.id,
|
id = document.id,
|
||||||
|
|
@ -189,7 +183,7 @@ class Processor(AsyncProcessor):
|
||||||
if v.operation is None:
|
if v.operation is None:
|
||||||
raise RequestError("Null operation")
|
raise RequestError("Null operation")
|
||||||
|
|
||||||
print("op", v.operation)
|
print("requets", v.operation)
|
||||||
|
|
||||||
impls = {
|
impls = {
|
||||||
"add-document": self.librarian.add_document,
|
"add-document": self.librarian.add_document,
|
||||||
|
|
@ -206,14 +200,10 @@ class Processor(AsyncProcessor):
|
||||||
if v.operation not in impls:
|
if v.operation not in impls:
|
||||||
raise RequestError(f"Invalid operation: {v.operation}")
|
raise RequestError(f"Invalid operation: {v.operation}")
|
||||||
|
|
||||||
print("HANDLING...")
|
|
||||||
|
|
||||||
return await impls[v.operation](v)
|
return await impls[v.operation](v)
|
||||||
|
|
||||||
async def on_librarian_request(self, msg, consumer, flow):
|
async def on_librarian_request(self, msg, consumer, flow):
|
||||||
|
|
||||||
print("REQUEST")
|
|
||||||
|
|
||||||
v = msg.value()
|
v = msg.value()
|
||||||
|
|
||||||
# Sender-produced ID
|
# Sender-produced ID
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ class TableStore:
|
||||||
|
|
||||||
async def list_documents(self, user):
|
async def list_documents(self, user):
|
||||||
|
|
||||||
print("LIST")
|
print("List documents...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
|
@ -448,7 +448,6 @@ class TableStore:
|
||||||
(user,)
|
(user,)
|
||||||
)
|
)
|
||||||
|
|
||||||
print("OK")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -479,15 +478,13 @@ class TableStore:
|
||||||
for row in resp
|
for row in resp
|
||||||
]
|
]
|
||||||
|
|
||||||
print("OK3")
|
print("Done")
|
||||||
|
|
||||||
print(lst)
|
|
||||||
|
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
async def get_document(self, user, id):
|
async def get_document(self, user, id):
|
||||||
|
|
||||||
print("GET")
|
print("Get document")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
|
@ -498,7 +495,6 @@ class TableStore:
|
||||||
(user, id)
|
(user, id)
|
||||||
)
|
)
|
||||||
|
|
||||||
print("OK")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -526,13 +522,15 @@ class TableStore:
|
||||||
tags = row[5],
|
tags = row[5],
|
||||||
object_id = row[6],
|
object_id = row[6],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print("Done")
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
raise RuntimeError("No such document row?")
|
raise RuntimeError("No such document row?")
|
||||||
|
|
||||||
async def get_document_object_id(self, user, id):
|
async def get_document_object_id(self, user, id):
|
||||||
|
|
||||||
print("GET")
|
print("Get document obj ID")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
|
@ -543,7 +541,6 @@ class TableStore:
|
||||||
(user, id)
|
(user, id)
|
||||||
)
|
)
|
||||||
|
|
||||||
print("OK")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -553,6 +550,7 @@ class TableStore:
|
||||||
|
|
||||||
|
|
||||||
for row in resp:
|
for row in resp:
|
||||||
|
print("Done")
|
||||||
return row[6]
|
return row[6]
|
||||||
|
|
||||||
raise RuntimeError("No such document row?")
|
raise RuntimeError("No such document row?")
|
||||||
|
|
@ -627,7 +625,7 @@ class TableStore:
|
||||||
|
|
||||||
async def list_processing(self, user):
|
async def list_processing(self, user):
|
||||||
|
|
||||||
print("LIST processing")
|
print("List processing objects")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
|
@ -638,7 +636,6 @@ class TableStore:
|
||||||
(user,)
|
(user,)
|
||||||
)
|
)
|
||||||
|
|
||||||
print("OK")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -660,9 +657,7 @@ class TableStore:
|
||||||
for row in resp
|
for row in resp
|
||||||
]
|
]
|
||||||
|
|
||||||
print("OK3")
|
print("Done")
|
||||||
|
|
||||||
print(lst)
|
|
||||||
|
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue