mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 17:36:23 +02:00
KG core upload/download uses query params (#405)
This commit is contained in:
parent
6f964e478e
commit
2e577e900a
5 changed files with 16 additions and 17 deletions
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
import asyncio
|
||||
import json
|
||||
import uuid
|
||||
import msgpack
|
||||
from . knowledge import KnowledgeRequestor
|
||||
|
|
@ -10,10 +9,10 @@ class CoreExport:
|
|||
def __init__(self, pulsar_client):
|
||||
self.pulsar_client = pulsar_client
|
||||
|
||||
async def process(self, data, error, ok, params):
|
||||
async def process(self, data, error, ok, request):
|
||||
|
||||
id = params["id"]
|
||||
user = params["user"]
|
||||
id = request.query["id"]
|
||||
user = request.query["user"]
|
||||
|
||||
response = await ok()
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ class CoreImport:
|
|||
def __init__(self, pulsar_client):
|
||||
self.pulsar_client = pulsar_client
|
||||
|
||||
async def process(self, data, error, ok, params):
|
||||
async def process(self, data, error, ok, request):
|
||||
|
||||
id = params["id"]
|
||||
user = params["user"]
|
||||
id = request.query["id"]
|
||||
user = request.query["user"]
|
||||
|
||||
kr = KnowledgeRequestor(
|
||||
pulsar_client = self.pulsar_client,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
import asyncio
|
||||
from aiohttp import web
|
||||
import uuid
|
||||
import json
|
||||
import msgpack
|
||||
|
||||
from . config import ConfigRequestor
|
||||
from . flow import FlowRequestor
|
||||
|
|
@ -110,15 +108,15 @@ class DispatcherManager:
|
|||
def dispatch_core_import(self):
|
||||
return DispatcherWrapper(self.process_core_import)
|
||||
|
||||
async def process_core_import(self, data, error, ok, params):
|
||||
async def process_core_import(self, data, error, ok, request):
|
||||
|
||||
ci = CoreImport(self.pulsar_client)
|
||||
return await ci.process(data, error, ok, params)
|
||||
return await ci.process(data, error, ok, request)
|
||||
|
||||
async def process_core_export(self, data, error, ok, params):
|
||||
async def process_core_export(self, data, error, ok, request):
|
||||
|
||||
ce = CoreExport(self.pulsar_client)
|
||||
return await ce.process(data, error, ok, params)
|
||||
return await ce.process(data, error, ok, request)
|
||||
|
||||
async def process_global_service(self, data, responder, params):
|
||||
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ class EndpointManager:
|
|||
dispatcher = dispatcher_manager.dispatch_flow_export()
|
||||
),
|
||||
StreamEndpoint(
|
||||
endpoint_path = "/api/v1/import-core/{user}/{id:.*}",
|
||||
endpoint_path = "/api/v1/import-core",
|
||||
auth = auth,
|
||||
dispatcher = dispatcher_manager.dispatch_core_import(),
|
||||
),
|
||||
StreamEndpoint(
|
||||
endpoint_path = "/api/v1/export-core/{user}/{id:.*}",
|
||||
endpoint_path = "/api/v1/export-core",
|
||||
auth = auth,
|
||||
dispatcher = dispatcher_manager.dispatch_core_export(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ class StreamEndpoint:
|
|||
async def error(err):
|
||||
return web.HTTPInternalServerError(text = err)
|
||||
|
||||
async def ok(status=200, reason="OK", type="application/octet-stream"):
|
||||
async def ok(
|
||||
status=200, reason="OK", type="application/octet-stream"
|
||||
):
|
||||
response = web.StreamResponse(
|
||||
status = status, reason = reason,
|
||||
headers = {"Content-Type": type}
|
||||
|
|
@ -58,7 +60,7 @@ class StreamEndpoint:
|
|||
return response
|
||||
|
||||
resp = await self.dispatcher.process(
|
||||
data, error, ok, request.match_info
|
||||
data, error, ok, request
|
||||
)
|
||||
|
||||
return resp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue