mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 11:41:02 +02:00
Remove processing works
This commit is contained in:
parent
73538e92ca
commit
c06918a677
4 changed files with 78 additions and 8 deletions
|
|
@ -102,7 +102,7 @@ def serialize_document_metadata(message):
|
|||
if message.metadata:
|
||||
ret["metadata"] = serialize_subgraph(message.metadata)
|
||||
|
||||
if message.kind:
|
||||
if message.user:
|
||||
ret["user"] = message.user
|
||||
|
||||
if message.tags:
|
||||
|
|
@ -123,7 +123,7 @@ def serialize_processing_metadata(message):
|
|||
if message.time:
|
||||
ret["time"] = message.time
|
||||
|
||||
if message.kind:
|
||||
if message.flow:
|
||||
ret["flow"] = message.flow
|
||||
|
||||
if message.user:
|
||||
|
|
|
|||
|
|
@ -188,16 +188,28 @@ class Librarian:
|
|||
):
|
||||
raise RuntimeError("Processing already exists")
|
||||
|
||||
print("Does not already exist")
|
||||
|
||||
doc = await self.table_store.get_document(
|
||||
request.processing_metadata.user,
|
||||
request.processing_metadata.document_id
|
||||
)
|
||||
|
||||
print("Got doc")
|
||||
|
||||
object_id = await self.table_store.get_document_object_id(
|
||||
request.user,
|
||||
request.document_id
|
||||
request.processing_metadata.user,
|
||||
request.processing_metadata.document_id
|
||||
)
|
||||
|
||||
print("Got object ID")
|
||||
|
||||
content = await self.blob_store.get(
|
||||
object_id
|
||||
)
|
||||
|
||||
print("Got content")
|
||||
|
||||
print("Add processing...")
|
||||
|
||||
await self.table_store.add_processing(request.processing_metadata)
|
||||
|
|
@ -224,7 +236,7 @@ class Librarian:
|
|||
|
||||
if not await self.table_store.processing_exists(
|
||||
request.user,
|
||||
request.document_id,
|
||||
request.processing_id,
|
||||
):
|
||||
raise RuntimeError("Processing object does not exist")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
from .. schema import LibrarianRequest, LibrarianResponse
|
||||
from .. schema import DocumentMetadata, Error, Triple, Value
|
||||
from .. schema import DocumentMetadata, ProcessingMetadata
|
||||
from .. schema import Error, Triple, Value
|
||||
from .. knowledge import hash
|
||||
from .. exceptions import RequestError
|
||||
|
||||
|
|
@ -556,6 +557,21 @@ class TableStore:
|
|||
|
||||
raise RuntimeError("No such document row?")
|
||||
|
||||
async def processing_exists(self, user, id):
|
||||
|
||||
resp = self.cassandra.execute(
|
||||
self.test_processing_exists_stmt,
|
||||
( user, id )
|
||||
)
|
||||
|
||||
# If a row exists, document exists. It's a cursor, can't just
|
||||
# count the length
|
||||
|
||||
for row in resp:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def add_processing(self, processing):
|
||||
|
||||
print("Adding processing", processing.id)
|
||||
|
|
@ -568,8 +584,9 @@ class TableStore:
|
|||
self.insert_processing_stmt,
|
||||
(
|
||||
processing.id, processing.document_id,
|
||||
processing.time, processing.flow, processing.user,
|
||||
processing.collection, processing.tags
|
||||
int(processing.time * 1000), processing.flow,
|
||||
processing.user, processing.collection,
|
||||
processing.tags
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue