Remove processing works

This commit is contained in:
Cyber MacGeddon 2025-05-04 22:15:01 +01:00
parent 73538e92ca
commit c06918a677
4 changed files with 78 additions and 8 deletions

View file

@ -0,0 +1,41 @@
#!/usr/bin/env python3
import requests
import json
import sys
import base64
import time
url = "http://localhost:8088/api/v1/"
############################################################################
proc_id = "2714fc72-44ab-45f2-94dd-6773fc336535"
input = {
"operation": "remove-processing",
"user": "trustgraph",
"processing-id": proc_id,
}
resp = requests.post(
f"{url}librarian",
json=input,
)
print(resp.text)
resp = resp.json()
print(resp)
if "error" in resp:
print(f"Error: {resp['error']}")
sys.exit(1)
# print(resp["response"])
print(resp)
sys.exit(0)
############################################################################

View file

@ -102,7 +102,7 @@ def serialize_document_metadata(message):
if message.metadata: if message.metadata:
ret["metadata"] = serialize_subgraph(message.metadata) ret["metadata"] = serialize_subgraph(message.metadata)
if message.kind: if message.user:
ret["user"] = message.user ret["user"] = message.user
if message.tags: if message.tags:
@ -123,7 +123,7 @@ def serialize_processing_metadata(message):
if message.time: if message.time:
ret["time"] = message.time ret["time"] = message.time
if message.kind: if message.flow:
ret["flow"] = message.flow ret["flow"] = message.flow
if message.user: if message.user:

View file

@ -188,16 +188,28 @@ class Librarian:
): ):
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.user, request.processing_metadata.user,
request.document_id request.processing_metadata.document_id
) )
print("Got object ID")
content = await self.blob_store.get(
object_id
)
print("Got content")
print("Add processing...") print("Add processing...")
await self.table_store.add_processing(request.processing_metadata) await self.table_store.add_processing(request.processing_metadata)
@ -224,7 +236,7 @@ class Librarian:
if not await self.table_store.processing_exists( if not await self.table_store.processing_exists(
request.user, request.user,
request.document_id, request.processing_id,
): ):
raise RuntimeError("Processing object does not exist") raise RuntimeError("Processing object does not exist")

View file

@ -1,6 +1,7 @@
from .. schema import LibrarianRequest, LibrarianResponse 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 .. knowledge import hash
from .. exceptions import RequestError from .. exceptions import RequestError
@ -556,6 +557,21 @@ class TableStore:
raise RuntimeError("No such document row?") 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): async def add_processing(self, processing):
print("Adding processing", processing.id) print("Adding processing", processing.id)
@ -568,8 +584,9 @@ class TableStore:
self.insert_processing_stmt, self.insert_processing_stmt,
( (
processing.id, processing.document_id, processing.id, processing.document_id,
processing.time, processing.flow, processing.user, int(processing.time * 1000), processing.flow,
processing.collection, processing.tags processing.user, processing.collection,
processing.tags
) )
) )