From 5575e885e50879f48430baa81b37cd5d7e0fc33e Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Sat, 15 Feb 2025 12:25:26 +0000 Subject: [PATCH] Fix merge issues with api-key, conflicts with librarian changes (#309) --- trustgraph-base/trustgraph/base/base_processor.py | 2 ++ trustgraph-flow/trustgraph/agent/react/service.py | 4 ++-- trustgraph-flow/trustgraph/gateway/agent.py | 8 -------- .../trustgraph/gateway/document_embeddings_stream.py | 1 - .../trustgraph/gateway/graph_embeddings_stream.py | 1 - trustgraph-flow/trustgraph/gateway/mux.py | 1 - trustgraph-flow/trustgraph/gateway/requestor.py | 2 -- trustgraph-flow/trustgraph/gateway/sender.py | 1 - trustgraph-flow/trustgraph/gateway/service.py | 2 -- trustgraph-flow/trustgraph/gateway/triples_stream.py | 1 - trustgraph-flow/trustgraph/graph_rag.py | 8 ++++---- 11 files changed, 8 insertions(+), 23 deletions(-) diff --git a/trustgraph-base/trustgraph/base/base_processor.py b/trustgraph-base/trustgraph/base/base_processor.py index ebf2f46f..a8374538 100644 --- a/trustgraph-base/trustgraph/base/base_processor.py +++ b/trustgraph-base/trustgraph/base/base_processor.py @@ -35,6 +35,8 @@ class BaseProcessor: log_level = params.get("log_level", LogLevel.INFO) self.pulsar_host = pulsar_host + self.pulsar_api_key = pulsar_api_key + if pulsar_api_key: auth = pulsar.AuthenticationToken(pulsar_api_key) self.client = pulsar.Client( diff --git a/trustgraph-flow/trustgraph/agent/react/service.py b/trustgraph-flow/trustgraph/agent/react/service.py index 7544f008..2df0fa4d 100755 --- a/trustgraph-flow/trustgraph/agent/react/service.py +++ b/trustgraph-flow/trustgraph/agent/react/service.py @@ -220,7 +220,7 @@ class Processor(ConsumerProducer): print(f"History: {history}", flush=True) - def think(x): + async def think(x): print(f"Think: {x}", flush=True) @@ -233,7 +233,7 @@ class Processor(ConsumerProducer): await self.producer.send(r, properties={"id": id}) - def observe(x): + async def observe(x): print(f"Observe: {x}", flush=True) diff --git a/trustgraph-flow/trustgraph/gateway/agent.py b/trustgraph-flow/trustgraph/gateway/agent.py index f66e68b9..150b970e 100644 --- a/trustgraph-flow/trustgraph/gateway/agent.py +++ b/trustgraph-flow/trustgraph/gateway/agent.py @@ -7,18 +7,10 @@ from . endpoint import ServiceEndpoint from . requestor import ServiceRequestor class AgentRequestor(ServiceRequestor): -<<<<<<< HEAD def __init__(self, pulsar_client, timeout, auth): super(AgentRequestor, self).__init__( pulsar_client=pulsar_client, -======= - def __init__(self, pulsar_host, timeout, auth, pulsar_api_key=None): - - super(AgentRequestor, self).__init__( - pulsar_host=pulsar_host, - pulsar_api_key=pulsar_api_key, ->>>>>>> a5d5b4c (Add pulsar API token check) request_queue=agent_request_queue, response_queue=agent_response_queue, request_schema=AgentRequest, diff --git a/trustgraph-flow/trustgraph/gateway/document_embeddings_stream.py b/trustgraph-flow/trustgraph/gateway/document_embeddings_stream.py index 790ea27e..6d7db576 100644 --- a/trustgraph-flow/trustgraph/gateway/document_embeddings_stream.py +++ b/trustgraph-flow/trustgraph/gateway/document_embeddings_stream.py @@ -28,7 +28,6 @@ class DocumentEmbeddingsStreamEndpoint(SocketEndpoint): self.pulsar_client, document_embeddings_store_queue, "api-gateway", "api-gateway", schema=JsonSchema(DocumentEmbeddings), - pulsar_api_key=self.pulsar_api_key ) async def listener(self, ws, running): diff --git a/trustgraph-flow/trustgraph/gateway/graph_embeddings_stream.py b/trustgraph-flow/trustgraph/gateway/graph_embeddings_stream.py index 30204b6b..385eb9f4 100644 --- a/trustgraph-flow/trustgraph/gateway/graph_embeddings_stream.py +++ b/trustgraph-flow/trustgraph/gateway/graph_embeddings_stream.py @@ -26,7 +26,6 @@ class GraphEmbeddingsStreamEndpoint(SocketEndpoint): self.subscriber = Subscriber( self.pulsar_client, graph_embeddings_store_queue, "api-gateway", "api-gateway", - pulsar_api_key=self.pulsar_api_key, schema=JsonSchema(GraphEmbeddings) ) diff --git a/trustgraph-flow/trustgraph/gateway/mux.py b/trustgraph-flow/trustgraph/gateway/mux.py index b03d156a..23b693ab 100644 --- a/trustgraph-flow/trustgraph/gateway/mux.py +++ b/trustgraph-flow/trustgraph/gateway/mux.py @@ -21,7 +21,6 @@ class MuxEndpoint(SocketEndpoint): self, pulsar_client, auth, services, path="/api/v1/socket", - pulsar_api_key=None ): super(MuxEndpoint, self).__init__( diff --git a/trustgraph-flow/trustgraph/gateway/requestor.py b/trustgraph-flow/trustgraph/gateway/requestor.py index 468159cd..68ab1b58 100644 --- a/trustgraph-flow/trustgraph/gateway/requestor.py +++ b/trustgraph-flow/trustgraph/gateway/requestor.py @@ -19,7 +19,6 @@ class ServiceRequestor: response_queue, response_schema, subscription="api-gateway", consumer_name="api-gateway", timeout=600, - pulsar_api_key=None, ): self.pub = Publisher( @@ -30,7 +29,6 @@ class ServiceRequestor: self.sub = Subscriber( pulsar_client, response_queue, subscription, consumer_name, - pulsar_api_key, JsonSchema(response_schema) ) diff --git a/trustgraph-flow/trustgraph/gateway/sender.py b/trustgraph-flow/trustgraph/gateway/sender.py index 1e8f5253..32c586b1 100644 --- a/trustgraph-flow/trustgraph/gateway/sender.py +++ b/trustgraph-flow/trustgraph/gateway/sender.py @@ -17,7 +17,6 @@ class ServiceSender: self, pulsar_client, request_queue, request_schema, - pulsar_api_key=None, ): self.pub = Publisher( diff --git a/trustgraph-flow/trustgraph/gateway/service.py b/trustgraph-flow/trustgraph/gateway/service.py index 8c26d5f4..d3122e3b 100755 --- a/trustgraph-flow/trustgraph/gateway/service.py +++ b/trustgraph-flow/trustgraph/gateway/service.py @@ -234,7 +234,6 @@ class Api: TriplesLoadEndpoint( pulsar_client=self.pulsar_client, auth = self.auth, - pulsar_api_key=self.pulsar_api_key, ), GraphEmbeddingsLoadEndpoint( pulsar_client=self.pulsar_client, @@ -248,7 +247,6 @@ class Api: pulsar_client=self.pulsar_client, auth = self.auth, services = self.services, - pulsar_api_key=self.pulsar_api_key, ), MetricsEndpoint( endpoint_path = "/api/v1/metrics", diff --git a/trustgraph-flow/trustgraph/gateway/triples_stream.py b/trustgraph-flow/trustgraph/gateway/triples_stream.py index 9a6a7434..a5d5ad0a 100644 --- a/trustgraph-flow/trustgraph/gateway/triples_stream.py +++ b/trustgraph-flow/trustgraph/gateway/triples_stream.py @@ -24,7 +24,6 @@ class TriplesStreamEndpoint(SocketEndpoint): self.subscriber = Subscriber( self.pulsar_client, triples_store_queue, "api-gateway", "api-gateway", - pulsar_api_key=self.pulsar_api_key, schema=JsonSchema(Triples) ) diff --git a/trustgraph-flow/trustgraph/graph_rag.py b/trustgraph-flow/trustgraph/graph_rag.py index a40ba32c..a1f9909e 100644 --- a/trustgraph-flow/trustgraph/graph_rag.py +++ b/trustgraph-flow/trustgraph/graph_rag.py @@ -208,7 +208,7 @@ class GraphRag: self.ge_client = GraphEmbeddingsClient( pulsar_host=pulsar_host, - pulsar_api_key=-pulsar_api_key, + pulsar_api_key=pulsar_api_key, subscriber=module + "-ge", input_queue=ge_request_queue, output_queue=ge_response_queue, @@ -216,7 +216,7 @@ class GraphRag: self.triples_client = TriplesQueryClient( pulsar_host=pulsar_host, - pulsar_api_key=-pulsar_api_key, + pulsar_api_key=pulsar_api_key, subscriber=module + "-tpl", input_queue=tpl_request_queue, output_queue=tpl_response_queue @@ -224,7 +224,7 @@ class GraphRag: self.embeddings = EmbeddingsClient( pulsar_host=pulsar_host, - pulsar_api_key=-pulsar_api_key, + pulsar_api_key=pulsar_api_key, input_queue=emb_request_queue, output_queue=emb_response_queue, subscriber=module + "-emb", @@ -238,7 +238,7 @@ class GraphRag: self.prompt = PromptClient( pulsar_host=pulsar_host, - pulsar_api_key=-pulsar_api_key, + pulsar_api_key=pulsar_api_key, input_queue=pr_request_queue, output_queue=pr_response_queue, subscriber=module + "-prompt",