From d028ba265c4a272b5af71b97cea8eb884080fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=84=E7=A3=8A?= Date: Mon, 3 Jun 2024 17:13:01 +0800 Subject: [PATCH] add test script --- charts/graphscope-interactive/README.md | 6 +- .../templates/primary/statefulset.yaml | 4 + .../sdk/examples/python/get_service_status.py | 79 +++++++++++++++++++ .../python/interactive_sdk/client/driver.py | 4 +- 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 flex/interactive/sdk/examples/python/get_service_status.py diff --git a/charts/graphscope-interactive/README.md b/charts/graphscope-interactive/README.md index f771d190123c..0f3d8d2cc8af 100644 --- a/charts/graphscope-interactive/README.md +++ b/charts/graphscope-interactive/README.md @@ -113,8 +113,7 @@ hiactorTimeout: 240000 ## TODO -- Currently we don't contains AdminService into deployment, either cypher/gremlin SDK. - +- TODO: Support cypher/gremlin queries. ## Installtion @@ -127,4 +126,5 @@ export ADMIN_ENDPOINT=${NODE_IP}:${ADMIN_PORT} export QUERY_ENDPOINT=${NODE_IP}:${QUERY_PORT} echo "ADMIN_ENDPOINT: ${ADMIN_ENDPOINT}" echo "QUERY_ENDPOINT: ${QUERY_ENDPOINT}" -``` \ No newline at end of file +``` + diff --git a/charts/graphscope-interactive/templates/primary/statefulset.yaml b/charts/graphscope-interactive/templates/primary/statefulset.yaml index ab3cb21787cc..b8c385730dcc 100644 --- a/charts/graphscope-interactive/templates/primary/statefulset.yaml +++ b/charts/graphscope-interactive/templates/primary/statefulset.yaml @@ -223,6 +223,10 @@ spec: ports: - name: query-port containerPort: {{ .Values.primary.service.queryPort }} + # - name: cypher-port + # containerPort: {{ .Values.primary.service.cypherPort }} + # - name: gremlin-port + # containerPort: {{ .Values.primary.service.gremlinPort }} {{- if .Values.primary.resources }} resources: {{- toYaml .Values.primary.resources | nindent 12 }} {{- end }} diff --git a/flex/interactive/sdk/examples/python/get_service_status.py b/flex/interactive/sdk/examples/python/get_service_status.py new file mode 100644 index 000000000000..b6dc8f7fef19 --- /dev/null +++ b/flex/interactive/sdk/examples/python/get_service_status.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import sys + +sys.path.append("../../python/") +import time +import argparse +import os +from interactive_sdk.client.driver import Driver +from interactive_sdk.client.session import Session +from interactive_sdk.openapi.models.query_request import QueryRequest +from interactive_sdk.openapi.models.gs_data_type import GSDataType +from interactive_sdk.openapi.models.typed_value import TypedValue +from interactive_sdk.openapi.models.primitive_type import PrimitiveType + + +def get_service_status(sess: Session): + print("Get service status") + status = sess.get_service_status() + print(status) + + +def get_procedures(sess: Session): + print("Get procedures") + procedures = sess.list_procedures("1") + print(procedures) + + +def call_procedure(sess: Session): + print("Call procedure") + req = QueryRequest( + query_name="QueryName", + arguments=[ + TypedValue( + type=GSDataType(PrimitiveType(primitive_type="DT_SIGNED_INT32")), + value=1, + ) + ], + ) + resp = sess.call_procedure("1", req) + print(resp) + + +if __name__ == "__main__": + # expect one argument: interactive_endpoint + parser = argparse.ArgumentParser(description="Example Python3 script") + + # Add arguments + parser.add_argument( + "--endpoint", + type=str, + help="The interactive endpoint to connect", + required=True, + default="https://virtserver.swaggerhub.com/GRAPHSCOPE/interactive/1.0.0/", + ) + + # Parse the arguments + args = parser.parse_args() + + driver = Driver(endpoint=args.endpoint) + with driver.session() as sess: + get_service_status(sess) + get_procedures(sess) + call_procedure(sess) diff --git a/flex/interactive/sdk/python/interactive_sdk/client/driver.py b/flex/interactive/sdk/python/interactive_sdk/client/driver.py index 8629decab195..1790e7a934f2 100644 --- a/flex/interactive/sdk/python/interactive_sdk/client/driver.py +++ b/flex/interactive/sdk/python/interactive_sdk/client/driver.py @@ -18,10 +18,8 @@ import sys -from gremlin_python import statics from gremlin_python.driver.client import Client -from gremlin_python.driver.driver_remote_connection import \ - DriverRemoteConnection +from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection from gremlin_python.process.graph_traversal import __ from gremlin_python.process.strategies import * from gremlin_python.structure.graph import Graph