Skip to content

Commit

Permalink
Fixes groot interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lidongze0629 committed Apr 10, 2024
1 parent 71df16c commit 9e62dcc
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def delete_receiver_by_id(receiver_id): # noqa: E501


@handle_api_exception()
def list_alert_messages(type=None, status=None, severity=None, start_time=None, end_time=None): # noqa: E501
def list_alert_messages(alert_type=None, status=None, severity=None, start_time=None, end_time=None): # noqa: E501
"""list_alert_messages
# noqa: E501
:param type:
:type type: str
:param alert_type:
:type alert_type: str
:param status:
:type status: str
:param severity:
Expand All @@ -59,7 +59,7 @@ def list_alert_messages(type=None, status=None, severity=None, start_time=None,
:rtype: Union[List[AlertMessage], Tuple[List[AlertMessage], int], Tuple[List[AlertMessage], int, Dict[str, str]]
"""
return alert_manager.list_alert_messages(type, status, severity, start_time, end_time)
return alert_manager.list_alert_messages(alert_type, status, severity, start_time, end_time)


@handle_api_exception()
Expand Down
46 changes: 26 additions & 20 deletions flex/coordinator/gs_flex_coordinator/core/insight/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,28 @@
# limitations under the License.
#

import itertools
import logging
import os
import time
from abc import ABCMeta, abstractmethod

import graphscope
from dateutil import tz
from graphscope.deploy.kubernetes.utils import get_service_endpoints, resolve_api_client
from graphscope.deploy.kubernetes.utils import (get_service_endpoints,
resolve_api_client)
from gremlin_python.driver.client import Client
from kubernetes import client as kube_client
from kubernetes import config as kube_config

from gs_flex_coordinator.core.config import (
CLUSTER_TYPE,
CREATION_TIME,
ENABLE_DNS,
GROOT_GREMLIN_PORT,
GROOT_GRPC_PORT,
GROOT_PASSWORD,
GROOT_USERNAME,
INSTANCE_NAME,
NAMESPACE,
WORKSPACE,
)
from gs_flex_coordinator.core.config import (CLUSTER_TYPE, CREATION_TIME,
ENABLE_DNS, GROOT_GREMLIN_PORT,
GROOT_GRPC_PORT, GROOT_PASSWORD,
GROOT_USERNAME, INSTANCE_NAME,
NAMESPACE, WORKSPACE)
from gs_flex_coordinator.core.scheduler import schedule
from gs_flex_coordinator.core.utils import (
data_type_to_groot,
encode_datetime,
get_internal_ip,
)
from gs_flex_coordinator.core.utils import (data_type_to_groot,
encode_datetime, get_internal_ip)
from gs_flex_coordinator.version import __version__


Expand Down Expand Up @@ -95,7 +87,7 @@ def to_dict(self):
"name": self._name,
"type": self._type,
"creation_time": self._creation_time,
"schema": self._schema,
"schema": self.schema,
"gremlin_interface": self._gremlin_interface,
"directed": self._directed,
}
Expand Down Expand Up @@ -147,9 +139,23 @@ def version(self):

@property
def schema(self):
def _transfer_data_type(dt):
if dt == "DOUBLE":
return "DT_DOUBLE"
elif dt == "LONG":
return "DT_SIGNED_INT64"
elif dt == "STRING":
return "DT_STRING"
else:
return dt

self._g.schema().update()
self._schema = self._g.schema().to_dict()
return self._schema
schema_copy = self._schema.copy()
for item in itertools.chain(schema_copy["vertices"], schema_copy["edges"]):
for p in item["properties"]:
p["type"] = _transfer_data_type(p["type"])
return schema_copy

@property
def conn(self):
Expand Down
15 changes: 15 additions & 0 deletions flex/coordinator/gs_flex_coordinator/core/insight/groot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# limitations under the License.
#

import itertools
import logging
import os
import pickle
Expand Down Expand Up @@ -149,6 +150,20 @@ def get_groot_schema(self, graph_name: str) -> dict:
return self._graph.schema

def import_groot_schema(self, graph_name: str, schema: dict) -> str:
def _data_type_to_groot(dt):
if dt == "DT_DOUBLE":
return "DOUBLE"
elif dt == "DT_SIGNED_INT64":
return "LONG"
elif dt == "DT_STRING":
return "STRING"
else:
return dt

# transfer to groot data type
for item in itertools.chain(schema["vertices"], schema["edges"]):
for p in item["properties"]:
p["type"] = _data_type_to_groot(p["type"])
return self._graph.import_schema(schema)

def list_jobs(self) -> List[dict]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def type(self, type: str):
:param type: The type of this GrootProperty.
:type type: str
"""
allowed_values = ["STRING", "LONG", "DOUBLE"] # noqa: E501
allowed_values = ["DT_STRING", "DT_SIGNED_INT64", "DT_DOUBLE"] # noqa: E501
if type not in allowed_values:
raise ValueError(
"Invalid value for `type` ({0}), must be one of {1}"
Expand Down
50 changes: 25 additions & 25 deletions flex/coordinator/gs_flex_coordinator/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ paths:
parameters:
- explode: true
in: query
name: type
name: alert_type
required: false
schema:
type: string
Expand Down Expand Up @@ -2826,21 +2826,21 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- label: label
properties:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
edges:
- label: label
relations:
Expand All @@ -2852,11 +2852,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- label: label
relations:
- src_label: src_label
Expand All @@ -2867,11 +2867,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
directed: true
gremlin_interface:
grpc_endpoint: grpc_endpoint
Expand Down Expand Up @@ -2910,21 +2910,21 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- label: label
properties:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
edges:
- label: label
relations:
Expand All @@ -2936,11 +2936,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- label: label
relations:
- src_label: src_label
Expand All @@ -2951,11 +2951,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
properties:
vertices:
items:
Expand All @@ -2977,11 +2977,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
properties:
label:
title: label
Expand All @@ -3006,11 +3006,11 @@ components:
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
- is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
properties:
label:
title: label
Expand All @@ -3033,7 +3033,7 @@ components:
is_primary_key: true
name: name
id: 0
type: STRING
type: DT_STRING
properties:
id:
format: int32
Expand All @@ -3044,9 +3044,9 @@ components:
type: string
type:
enum:
- STRING
- LONG
- DOUBLE
- DT_STRING
- DT_SIGNED_INT64
- DT_DOUBLE
title: type
type: string
is_primary_key:
Expand Down
8 changes: 4 additions & 4 deletions flex/openapi/openapi_coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ paths:
- alert
operationId: list_alert_messages
parameters:
- name: type
- name: alert_type
in: query
required: false
schema:
Expand Down Expand Up @@ -2250,9 +2250,9 @@ components:
type:
type: string
enum:
- STRING
- LONG
- DOUBLE
- DT_STRING
- DT_SIGNED_INT64
- DT_DOUBLE
is_primary_key:
type: boolean
GrootDataloadingJobConfig:
Expand Down
Loading

0 comments on commit 9e62dcc

Please sign in to comment.