Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_procedure_by_name interface #3681

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ def delete_procedure(graph_name, procedure_name): # noqa: E501
return client_wrapper.delete_procedure_by_name(graph_name, procedure_name)


@handle_api_exception()
def get_procedure(graph_name, procedure_name): # noqa: E501
"""get_procedure

Get a procedure by name # noqa: E501

:param graph_name:
:type graph_name: str
:param procedure_name:
:type procedure_name: str

:rtype: Union[Procedure, Tuple[Procedure, int], Tuple[Procedure, int, Dict[str, str]]
"""
return client_wrapper.get_procedure_by_name(graph_name, procedure_name)


@handle_api_exception()
def list_procedures(): # noqa: E501
"""list_procedures
Expand Down
5 changes: 5 additions & 0 deletions flex/coordinator/gs_flex_coordinator/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ def create_procedure(self, graph_name: str, procedure: Procedure) -> str:
procedure_dict = procedure.to_dict()
return self._client.create_procedure(graph_name, procedure_dict)

def get_procedure_by_name(self, graph_name: str, procedure_name: str) -> Procedure:
return Procedure.from_dict(
self._client.get_procedure_by_name(graph_name, procedure_name).to_dict()
)

def list_procedures(self, graph_name: Union[None, str]) -> List[Procedure]:
procedures = self._client.list_procedures(graph_name)
# transfer
Expand Down
7 changes: 7 additions & 0 deletions flex/coordinator/gs_flex_coordinator/core/interactive/hqps.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def delete_procedure_by_name(self, graph_name: str, procedure_name: str) -> str:
api_instance = hqps_client.ProcedureApi(api_client)
return api_instance.delete_procedure(graph_name, procedure_name)

def get_procedure_by_name(self, graph_name: str, procedure_name: str) -> Procedure:
with hqps_client.ApiClient(
hqps_client.Configuration(self._hqps_endpoint)
) as api_client:
api_instance = hqps_client.ProcedureApi(api_client)
return api_instance.get_procedure(graph_name, procedure_name)

def get_service_status(self) -> dict:
with hqps_client.ApiClient(
hqps_client.Configuration(self._hqps_endpoint)
Expand Down
121 changes: 60 additions & 61 deletions flex/coordinator/gs_flex_coordinator/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,34 @@ paths:
tags:
- procedure
x-openapi-router-controller: gs_flex_coordinator.controllers.procedure_controller
get:
description: Get a procedure by name
operationId: get_procedure
parameters:
- explode: false
in: path
name: graph_name
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: procedure_name
required: true
schema:
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Procedure'
description: successful operation
tags:
- procedure
x-openapi-router-controller: gs_flex_coordinator.controllers.procedure_controller
put:
description: Update stored procedure on a certain graph
operationId: update_procedure
Expand Down Expand Up @@ -1752,7 +1780,7 @@ components:
graph_name: mocking_graph
sdk_endpoints:
gremlin: ws://111.111.111.111:12312/gremlin
cypher: neo4j://111.111.111.111:7687
cypher: neo4j://mock.api.cypher:7676
hqps: neo4j://111.111.111.111:10000
grpc: 111.111.111.111:55556
status: running
Expand Down Expand Up @@ -2333,82 +2361,58 @@ components:
x-body-name: data_source
GrootGraph:
example:
creation_time: creation_time
name: demo
type: GrootGraph
directed: true
creation_time: 2024-02-29 12:00:00
gremlin_interface:
gremlin_endpoint: ws://127.0.0.1:12312/gremmin
grpc_endpoint: 127.0.0.1:55556
schema:
vertices:
- label: label
- label: person
properties:
- is_primary_key: true
name: name
id: 0
- name: id
type: STRING
- is_primary_key: true
name: name
id: 0
is_primary_key: true
- name: name
type: STRING
- label: label
is_primary_key: false
- label: software
properties:
- is_primary_key: true
name: name
id: 0
- name: id
type: STRING
- is_primary_key: true
name: name
id: 0
is_primary_key: true
- name: name
type: STRING
is_primary_key: false
edges:
- label: label
- label: knows
relations:
- src_label: src_label
dst_label: dst_label
- src_label: src_label
dst_label: dst_label
- src_label: person
dst_label: person
properties:
- is_primary_key: true
name: name
id: 0
type: STRING
- is_primary_key: true
name: name
id: 0
type: STRING
- label: label
- name: weight
type: DOUBLE
is_primary_key: false
- label: created
relations:
- src_label: src_label
dst_label: dst_label
- src_label: src_label
dst_label: dst_label
- src_label: person
dst_label: software
properties:
- is_primary_key: true
name: name
id: 0
type: STRING
- is_primary_key: true
name: name
id: 0
type: STRING
directed: true
gremlin_interface:
grpc_endpoint: grpc_endpoint
password: password
gremlin_endpoint: gremlin_endpoint
username: username
name: name
type: GrootGraph
- name: weight
type: DOUBLE
is_primary_key: false
properties:
name:
title: name
type: string
type:
enum:
- GrootGraph
title: type
type: string
directed:
title: directed
type: boolean
creation_time:
title: creation_time
type: string
schema:
$ref: '#/components/schemas/GrootSchema'
Expand Down Expand Up @@ -2738,12 +2742,12 @@ components:
ServiceStatus_sdk_endpoints:
example:
gremlin: ws://111.111.111.111:12312/gremlin
cypher: neo4j://111.111.111.111:7687
cypher: neo4j://mock.api.cypher:7676
hqps: neo4j://111.111.111.111:10000
grpc: 111.111.111.111:55556
properties:
cypher:
example: neo4j://111.111.111.111:7687
example: neo4j://mock.api.cypher:7676
title: cypher
type: string
gremlin:
Expand Down Expand Up @@ -2865,11 +2869,6 @@ components:
title: EdgeMapping_destination_vertex_mappings_inner
type: object
GrootGraph_gremlin_interface:
example:
grpc_endpoint: grpc_endpoint
password: password
gremlin_endpoint: gremlin_endpoint
username: username
properties:
gremlin_endpoint:
title: gremlin_endpoint
Expand Down
8 changes: 6 additions & 2 deletions flex/coordinator/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ def run(self):
"--package-name",
"gs_flex_coordinator",
]
env = os.environ.copy()
env["OPENAPI_GENERATOR_VERSION"] = "7.3.0"
print(" ".join(cmd))
subprocess.check_call(
cmd,
env=os.environ.copy(),
env=env,
)


Expand Down Expand Up @@ -107,10 +109,12 @@ def run(self):
"--package-name",
"hqps_client",
]
env = os.environ.copy()
env["OPENAPI_GENERATOR_VERSION"] = "7.3.0"
print(" ".join(cmd))
subprocess.check_call(
cmd,
env=os.environ.copy(),
env=env,
)
# cp
subprocess.run(["cp", "-r", os.path.join(tempdir, "hqps_client"), targetdir])
Expand Down
68 changes: 67 additions & 1 deletion flex/openapi/openapi_coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,29 @@ paths:
items:
$ref: '#/components/schemas/Procedure'
/api/v1/graph/{graph_name}/procedure/{procedure_name}:
get:
tags:
- procedure
description: Get a procedure by name
operationId: get_procedure
parameters:
- name: graph_name
in : path
required: true
schema:
type: string
- name: procedure_name
in : path
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Procedure'
put:
tags:
- procedure
Expand Down Expand Up @@ -1422,7 +1445,7 @@ components:
properties:
cypher:
type: string
example: neo4j://111.111.111.111:7687
example: neo4j://mock.api.cypher:7676
gremlin:
type: string
example: ws://111.111.111.111:12312/gremlin
Expand Down Expand Up @@ -1797,6 +1820,49 @@ components:
type: string
password:
type: string
example:
name: demo
type: GrootGraph
directed: true
creation_time: 2024-02-29 12:00:00
gremlin_interface:
gremlin_endpoint: ws://127.0.0.1:12312/gremmin
grpc_endpoint: 127.0.0.1:55556
schema:
vertices:
- label: person
properties:
- name: id
type: STRING
is_primary_key: true
- name: name
type: STRING
is_primary_key: false
- label: software
properties:
- name: id
type: STRING
is_primary_key: true
- name: name
type: STRING
is_primary_key: false
edges:
- label: knows
relations:
- src_label: person
dst_label: person
properties:
- name: weight
type: DOUBLE
is_primary_key: false
- label: created
relations:
- src_label: person
dst_label: software
properties:
- name: weight
type: DOUBLE
is_primary_key: false
GrootSchema:
x-body-name: groot_schema
type: object
Expand Down
4 changes: 3 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def run(self):
"--package-name",
"graphscope.flex.rest",
]
env = os.environ.copy()
env["OPENAPI_GENERATOR_VERSION"] = "7.3.0"
print(" ".join(cmd))
subprocess.check_call(
cmd,
env=os.environ.copy(),
env=env,
)
# cp
subprocess.run(
Expand Down
Loading