Skip to content

Commit 1211ee1

Browse files
authored
refactor(core): Reorg the building of openapi-related code (#4481)
- Generate flex python code in-place rather copy from temporary directory. - Update coordinator code. - Python code format. - Align coordinator' data type same with interactive. Fix #4471 , Fix #4470 - Maintain long_text.py, date_type.py and time_stamp_type.py in our codebase, since the auto generated code fails at deserialization. Note that although coordinator's flex-related code could also be generated when needed, but we still preserve them in the code base for reference.
1 parent 4a60a10 commit 1211ee1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1412
-236
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ core.*
103103

104104
# Openapi generated code
105105
python/graphscope/flex/rest
106+
python/.openapi-generator/
107+
!python/graphscope/flex/rest/models/time_stamp_type.py
108+
!python/graphscope/flex/rest/models/date_type.py
109+
!python/graphscope/flex/rest/models/long_text.py
110+
111+
.openapi-generator/
112+
113+
coordinator/gscoordinator/flex/test/
106114

107115
# Flex related
108116
flex/docs/
@@ -156,6 +164,8 @@ flex/interactive/sdk/python/gs_interactive/exceptions.py
156164
flex/interactive/sdk/python/gs_interactive/rest.py
157165
!flex/interactive/sdk/python/gs_interactive/client/generated/__init__.py
158166
!flex/interactive/sdk/python/gs_interactive/models/long_text.py
167+
!flex/interactive/sdk/python/gs_interactive/models/time_stamp_type.py
168+
!flex/interactive/sdk/python/gs_interactive/models/date_type.py
159169

160170

161171
**/.cache/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# OpenAPI Generator Ignore
2+
.dockerignore
3+
.gitignore
4+
.gitlab-ci.yml
5+
.travis.yml
6+
git_push.sh
7+
pyproject.toml
8+
requirements.txt
9+
setup.cfg
10+
setup.py
11+
test-requirements.txt
12+
tox.ini
13+
python.yml
14+
.openapi-generator/VERSION
15+
.openapi-generator/FILES
16+
README.md
17+
18+
VERSION
19+
FILES
20+
Dockerfile
21+
22+
gscoordinator/flex/__init__.py
23+
gscoordinator/flex/__main__.py
24+
gscoordinator/flex/controllers/

coordinator/graphscope_runtime/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616
# limitations under the License.
1717
#
1818

19-
"""Dummy package dir for gs-engine package
20-
"""
19+
"""Dummy package dir for gs-engine package"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

coordinator/gscoordinator/flex/models/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from gscoordinator.flex.models.edge_mapping import EdgeMapping
3030
from gscoordinator.flex.models.edge_mapping_type_triplet import EdgeMappingTypeTriplet
3131
from gscoordinator.flex.models.error import Error
32+
from gscoordinator.flex.models.fixed_char import FixedChar
33+
from gscoordinator.flex.models.fixed_char_char import FixedCharChar
3234
from gscoordinator.flex.models.gs_data_type import GSDataType
3335
from gscoordinator.flex.models.get_alert_message_response import GetAlertMessageResponse
3436
from gscoordinator.flex.models.get_alert_receiver_response import GetAlertReceiverResponse
@@ -61,7 +63,10 @@
6163
from gscoordinator.flex.models.temporal_type import TemporalType
6264
from gscoordinator.flex.models.temporal_type_temporal import TemporalTypeTemporal
6365
from gscoordinator.flex.models.time_stamp_type import TimeStampType
66+
from gscoordinator.flex.models.typed_value import TypedValue
6467
from gscoordinator.flex.models.update_alert_message_status_request import UpdateAlertMessageStatusRequest
6568
from gscoordinator.flex.models.update_stored_proc_request import UpdateStoredProcRequest
6669
from gscoordinator.flex.models.upload_file_response import UploadFileResponse
70+
from gscoordinator.flex.models.var_char import VarChar
71+
from gscoordinator.flex.models.var_char_var_char import VarCharVarChar
6772
from gscoordinator.flex.models.vertex_mapping import VertexMapping

coordinator/gscoordinator/flex/models/base_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def to_dict(self):
4343
if hasattr(item[1], "to_dict") else item,
4444
value.items()
4545
))
46-
else:
46+
elif value is not None:
4747
result[attr] = value
4848

4949
return result
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from datetime import date, datetime # noqa: F401
2+
3+
from typing import List, Dict # noqa: F401
4+
5+
from gscoordinator.flex.models.base_model import Model
6+
from gscoordinator.flex.models.fixed_char_char import FixedCharChar
7+
from gscoordinator.flex import util
8+
9+
from gscoordinator.flex.models.fixed_char_char import FixedCharChar # noqa: E501
10+
11+
class FixedChar(Model):
12+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13+
14+
Do not edit the class manually.
15+
"""
16+
17+
def __init__(self, char=None): # noqa: E501
18+
"""FixedChar - a model defined in OpenAPI
19+
20+
:param char: The char of this FixedChar. # noqa: E501
21+
:type char: FixedCharChar
22+
"""
23+
self.openapi_types = {
24+
'char': FixedCharChar
25+
}
26+
27+
self.attribute_map = {
28+
'char': 'char'
29+
}
30+
31+
self._char = char
32+
33+
@classmethod
34+
def from_dict(cls, dikt) -> 'FixedChar':
35+
"""Returns the dict as a model
36+
37+
:param dikt: A dict.
38+
:type: dict
39+
:return: The FixedChar of this FixedChar. # noqa: E501
40+
:rtype: FixedChar
41+
"""
42+
return util.deserialize_model(dikt, cls)
43+
44+
@property
45+
def char(self) -> FixedCharChar:
46+
"""Gets the char of this FixedChar.
47+
48+
49+
:return: The char of this FixedChar.
50+
:rtype: FixedCharChar
51+
"""
52+
return self._char
53+
54+
@char.setter
55+
def char(self, char: FixedCharChar):
56+
"""Sets the char of this FixedChar.
57+
58+
59+
:param char: The char of this FixedChar.
60+
:type char: FixedCharChar
61+
"""
62+
if char is None:
63+
raise ValueError("Invalid value for `char`, must not be `None`") # noqa: E501
64+
65+
self._char = char
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from datetime import date, datetime # noqa: F401
2+
3+
from typing import List, Dict # noqa: F401
4+
5+
from gscoordinator.flex.models.base_model import Model
6+
from gscoordinator.flex import util
7+
8+
9+
class FixedCharChar(Model):
10+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
12+
Do not edit the class manually.
13+
"""
14+
15+
def __init__(self, fixed_length=None): # noqa: E501
16+
"""FixedCharChar - a model defined in OpenAPI
17+
18+
:param fixed_length: The fixed_length of this FixedCharChar. # noqa: E501
19+
:type fixed_length: int
20+
"""
21+
self.openapi_types = {
22+
'fixed_length': int
23+
}
24+
25+
self.attribute_map = {
26+
'fixed_length': 'fixed_length'
27+
}
28+
29+
self._fixed_length = fixed_length
30+
31+
@classmethod
32+
def from_dict(cls, dikt) -> 'FixedCharChar':
33+
"""Returns the dict as a model
34+
35+
:param dikt: A dict.
36+
:type: dict
37+
:return: The FixedChar_char of this FixedCharChar. # noqa: E501
38+
:rtype: FixedCharChar
39+
"""
40+
return util.deserialize_model(dikt, cls)
41+
42+
@property
43+
def fixed_length(self) -> int:
44+
"""Gets the fixed_length of this FixedCharChar.
45+
46+
47+
:return: The fixed_length of this FixedCharChar.
48+
:rtype: int
49+
"""
50+
return self._fixed_length
51+
52+
@fixed_length.setter
53+
def fixed_length(self, fixed_length: int):
54+
"""Sets the fixed_length of this FixedCharChar.
55+
56+
57+
:param fixed_length: The fixed_length of this FixedCharChar.
58+
:type fixed_length: int
59+
"""
60+
if fixed_length is None:
61+
raise ValueError("Invalid value for `fixed_length`, must not be `None`") # noqa: E501
62+
63+
self._fixed_length = fixed_length

coordinator/gscoordinator/flex/models/get_stored_proc_response.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GetStoredProcResponse(Model):
1414
Do not edit the class manually.
1515
"""
1616

17-
def __init__(self, name=None, description=None, type=None, query=None, id=None, library=None, params=None, returns=None, bound_graph=None, runnable=None): # noqa: E501
17+
def __init__(self, name=None, description=None, type=None, query=None, id=None, library=None, params=None, returns=None, option=None, bound_graph=None, runnable=None): # noqa: E501
1818
"""GetStoredProcResponse - a model defined in OpenAPI
1919
2020
:param name: The name of this GetStoredProcResponse. # noqa: E501
@@ -33,6 +33,8 @@ def __init__(self, name=None, description=None, type=None, query=None, id=None,
3333
:type params: List[Parameter]
3434
:param returns: The returns of this GetStoredProcResponse. # noqa: E501
3535
:type returns: List[Parameter]
36+
:param option: The option of this GetStoredProcResponse. # noqa: E501
37+
:type option: Dict[str, object]
3638
:param bound_graph: The bound_graph of this GetStoredProcResponse. # noqa: E501
3739
:type bound_graph: str
3840
:param runnable: The runnable of this GetStoredProcResponse. # noqa: E501
@@ -47,6 +49,7 @@ def __init__(self, name=None, description=None, type=None, query=None, id=None,
4749
'library': str,
4850
'params': List[Parameter],
4951
'returns': List[Parameter],
52+
'option': Dict[str, object],
5053
'bound_graph': str,
5154
'runnable': bool
5255
}
@@ -60,6 +63,7 @@ def __init__(self, name=None, description=None, type=None, query=None, id=None,
6063
'library': 'library',
6164
'params': 'params',
6265
'returns': 'returns',
66+
'option': 'option',
6367
'bound_graph': 'bound_graph',
6468
'runnable': 'runnable'
6569
}
@@ -72,6 +76,7 @@ def __init__(self, name=None, description=None, type=None, query=None, id=None,
7276
self._library = library
7377
self._params = params
7478
self._returns = returns
79+
self._option = option
7580
self._bound_graph = bound_graph
7681
self._runnable = runnable
7782

@@ -272,6 +277,27 @@ def returns(self, returns: List[Parameter]):
272277

273278
self._returns = returns
274279

280+
@property
281+
def option(self) -> Dict[str, object]:
282+
"""Gets the option of this GetStoredProcResponse.
283+
284+
285+
:return: The option of this GetStoredProcResponse.
286+
:rtype: Dict[str, object]
287+
"""
288+
return self._option
289+
290+
@option.setter
291+
def option(self, option: Dict[str, object]):
292+
"""Sets the option of this GetStoredProcResponse.
293+
294+
295+
:param option: The option of this GetStoredProcResponse.
296+
:type option: Dict[str, object]
297+
"""
298+
299+
self._option = option
300+
275301
@property
276302
def bound_graph(self) -> str:
277303
"""Gets the bound_graph of this GetStoredProcResponse.

coordinator/gscoordinator/flex/models/parameter.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,31 @@ class Parameter(Model):
1414
Do not edit the class manually.
1515
"""
1616

17-
def __init__(self, name=None, type=None): # noqa: E501
17+
def __init__(self, name=None, type=None, allow_cast=None): # noqa: E501
1818
"""Parameter - a model defined in OpenAPI
1919
2020
:param name: The name of this Parameter. # noqa: E501
2121
:type name: str
2222
:param type: The type of this Parameter. # noqa: E501
2323
:type type: GSDataType
24+
:param allow_cast: The allow_cast of this Parameter. # noqa: E501
25+
:type allow_cast: bool
2426
"""
2527
self.openapi_types = {
2628
'name': str,
27-
'type': GSDataType
29+
'type': GSDataType,
30+
'allow_cast': bool
2831
}
2932

3033
self.attribute_map = {
3134
'name': 'name',
32-
'type': 'type'
35+
'type': 'type',
36+
'allow_cast': 'allow_cast'
3337
}
3438

3539
self._name = name
3640
self._type = type
41+
self._allow_cast = allow_cast
3742

3843
@classmethod
3944
def from_dict(cls, dikt) -> 'Parameter':
@@ -91,3 +96,24 @@ def type(self, type: GSDataType):
9196
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
9297

9398
self._type = type
99+
100+
@property
101+
def allow_cast(self) -> bool:
102+
"""Gets the allow_cast of this Parameter.
103+
104+
105+
:return: The allow_cast of this Parameter.
106+
:rtype: bool
107+
"""
108+
return self._allow_cast
109+
110+
@allow_cast.setter
111+
def allow_cast(self, allow_cast: bool):
112+
"""Sets the allow_cast of this Parameter.
113+
114+
115+
:param allow_cast: The allow_cast of this Parameter.
116+
:type allow_cast: bool
117+
"""
118+
119+
self._allow_cast = allow_cast

0 commit comments

Comments
 (0)