Skip to content

Commit

Permalink
add test script
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglei1949 committed Jun 3, 2024
1 parent d0ca344 commit d028ba2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
6 changes: 3 additions & 3 deletions charts/graphscope-interactive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
79 changes: 79 additions & 0 deletions flex/interactive/sdk/examples/python/get_service_status.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 1 addition & 3 deletions flex/interactive/sdk/python/interactive_sdk/client/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d028ba2

Please sign in to comment.