Skip to content

Commit

Permalink
bugfix remote client
Browse files Browse the repository at this point in the history
  • Loading branch information
royzhao committed Oct 25, 2024
1 parent 593700b commit aef3429
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
6 changes: 4 additions & 2 deletions python/knext/knext/builder/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
from knext.builder import rest
from knext.builder.rest.models.writer_graph_request import WriterGraphRequest
from knext.common.base.client import Client
from knext.common.rest import ApiClient, Configuration


class BuilderClient(Client):
""" """

_rest_client = rest.BuilderApi()

def __init__(self, host_addr: str = None, project_id: int = None):
super().__init__(host_addr, project_id)
self._rest_client: rest.BuilderApi = rest.BuilderApi(
api_client=ApiClient(configuration=Configuration(host=host_addr)))


def write_graph(self, sub_graph: dict, operation: str, lead_to_builder: bool):
request = WriterGraphRequest(
Expand Down
2 changes: 1 addition & 1 deletion python/knext/knext/common/rest/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
from knext.common import env

self.host = (
os.environ.get("KAG_PROJECT_HOST_ADDR") or host or env.LOCAL_SCHEMA_URL
host or os.environ.get("KAG_PROJECT_HOST_ADDR") or env.LOCAL_SCHEMA_URL
)
"""Default Base url
"""
Expand Down
5 changes: 3 additions & 2 deletions python/knext/knext/graph_algo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import List, Dict

from knext.common.base.client import Client
from knext.common.rest import ApiClient, Configuration
from knext.graph_algo import (
GetPageRankScoresRequest,
GetPageRankScoresRequestStartNodes,
Expand All @@ -23,10 +24,10 @@
class GraphAlgoClient(Client):
""" """

_rest_client = rest.GraphApi()

def __init__(self, host_addr: str = None, project_id: int = None):
super().__init__(host_addr, project_id)
self._rest_client: rest.GraphApi = rest.GraphApi(
api_client=ApiClient(configuration=Configuration(host=host_addr)))

def calculate_pagerank_scores(self, target_vertex_type, start_nodes: List[Dict]):
"""
Expand Down
7 changes: 4 additions & 3 deletions python/knext/knext/project/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
import json

from knext.common.base.client import Client
from knext.common.rest import Configuration, ApiClient
from knext.project import rest


class ProjectClient(Client):
""" """

_rest_client = rest.ProjectApi()

def __init__(self, host_addr: str = None, project_id: int = None):
super().__init__(host_addr, project_id)
self._rest_client: rest.ProjectApi = rest.ProjectApi(
api_client=ApiClient(configuration=Configuration(host=host_addr)))

def get_config(self, project_id: str):
project = self.get(id=int(project_id))
Expand All @@ -36,7 +37,7 @@ def get(self, **conditions):
for project in projects:
condition = True
for k, v in conditions.items():
condition = condition and getattr(project, k) == v
condition = condition and str(getattr(project, k)) == str(v)
if condition:
return project
return None
Expand Down
6 changes: 3 additions & 3 deletions python/knext/knext/reasoner/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import knext.common.cache
from knext.common.base.client import Client
from knext.common.rest import ApiClient, Configuration
from knext.project.client import ProjectClient
from knext.reasoner import ReasonTask
from knext.reasoner import rest
Expand All @@ -25,11 +26,10 @@

class ReasonerClient(Client):
"""SPG Reasoner Client."""

_rest_client = rest.ReasonerApi()

def __init__(self, host_addr: str = None, project_id: int = None, namespace=None):
super().__init__(host_addr, project_id)
self._rest_client: rest.ReasonerApi = rest.ReasonerApi(
api_client=ApiClient(configuration=Configuration(host=host_addr)))
self._namespace = namespace or os.environ.get("KAG_PROJECT_NAMESPACE")
self._session = None
# load schema cache
Expand Down
5 changes: 3 additions & 2 deletions python/knext/knext/search/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# or implied.

from knext.common.base.client import Client
from knext.common.rest import Configuration, ApiClient

from knext.search import rest, TextSearchRequest, VectorSearchRequest, IdxRecord

Expand All @@ -21,10 +22,10 @@ def idx_record_to_dict(record: IdxRecord):
class SearchClient(Client):
""" """

_rest_client = rest.SearchApi()

def __init__(self, host_addr: str = None, project_id: int = None):
super().__init__(host_addr, project_id)
self._rest_client: rest.SearchApi = rest.SearchApi(
api_client=ApiClient(configuration=Configuration(host=host_addr)))

def search_text(self, query_string, label_constraints=None, topk=10):
req = TextSearchRequest(self._project_id, query_string, label_constraints, topk)
Expand Down

0 comments on commit aef3429

Please sign in to comment.