mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-12-26 14:46:42 +00:00
fix(knext): fix bugs and add debug mode (#84)
Co-authored-by: baifuyu <fuyu.bfy@antgroup.com>
This commit is contained in:
parent
d5822f7e74
commit
440fb6128e
@ -96,6 +96,15 @@ class BuilderClient(Client):
|
||||
if kwargs.get("lead_to"):
|
||||
java_cmd.append("--leadTo")
|
||||
|
||||
if os.getenv("KNEXT_DEBUG_MODE", "False") == "True":
|
||||
print_java_cmd = [
|
||||
cmd if not cmd.startswith("{") else f"'{cmd}'" for cmd in java_cmd
|
||||
]
|
||||
print_java_cmd = [
|
||||
cmd if not cmd.count(";") > 0 else f"'{cmd}'" for cmd in print_java_cmd
|
||||
]
|
||||
print(json.dumps(" ".join(print_java_cmd))[1:-1].replace("'", '"'))
|
||||
|
||||
subprocess.call(java_cmd)
|
||||
|
||||
def query(self, job_inst_id: int):
|
||||
|
||||
@ -467,7 +467,12 @@ class BaseProperty(ABC):
|
||||
members = inspect.getmembers(self.__class__)
|
||||
for name, member in members:
|
||||
if isinstance(member, property):
|
||||
setattr(self, name, getattr(other, name))
|
||||
if name == "sub_properties":
|
||||
setattr(
|
||||
self, name, [prop for _, prop in getattr(other, name).items()]
|
||||
)
|
||||
else:
|
||||
setattr(self, name, getattr(other, name))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
|
||||
@ -9,8 +9,7 @@
|
||||
# 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.
|
||||
|
||||
|
||||
import os
|
||||
from json import JSONDecodeError
|
||||
from typing import Any
|
||||
|
||||
@ -26,15 +25,15 @@ class _ApiExceptionHandler(Group):
|
||||
"""Echo exceptions."""
|
||||
|
||||
def invoke(self, ctx: Context) -> Any:
|
||||
return super().invoke(ctx)
|
||||
# # TODO
|
||||
# try:
|
||||
# return super().invoke(ctx)
|
||||
# except ApiException as api:
|
||||
# try:
|
||||
# body = json.loads(api.body)
|
||||
# except JSONDecodeError:
|
||||
# raise api
|
||||
# click.secho("ERROR: " + body, fg="bright_red")
|
||||
# except Exception as e:
|
||||
# click.secho("ERROR: " + e.__str__(), fg="bright_red")
|
||||
if os.getenv("KNEXT_DEBUG_MODE", "False") == "True":
|
||||
return super().invoke(ctx)
|
||||
try:
|
||||
return super().invoke(ctx)
|
||||
except ApiException as api:
|
||||
try:
|
||||
body = json.loads(api.body)
|
||||
except JSONDecodeError:
|
||||
raise api
|
||||
click.secho("ERROR: " + body, fg="bright_red")
|
||||
except Exception as e:
|
||||
click.secho("ERROR: " + e.__str__(), fg="bright_red")
|
||||
|
||||
@ -227,12 +227,9 @@ from knext.rest.models.builder.pipeline.config.operator_predicting_config import
|
||||
OperatorPredictingConfig,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.predicting_config import PredictingConfig
|
||||
from knext.rest.models.builder.pipeline.config.new_instance_fusing_config import (
|
||||
NewInstanceFusingConfig,
|
||||
from knext.rest.models.builder.pipeline.config.overwrite_fusing_config import (
|
||||
OverwriteFusingConfig,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.spg_type_mapping_node_configs import (
|
||||
SpgTypeMappingNodeConfigs,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.not_import_fusing_config import (
|
||||
NotImportFusingConfig,
|
||||
)
|
||||
|
||||
@ -154,7 +154,6 @@ class ApiClient(object):
|
||||
_request_timeout=None,
|
||||
_host=None,
|
||||
):
|
||||
|
||||
config = self.configuration
|
||||
|
||||
# header parameters
|
||||
@ -765,7 +764,6 @@ class ApiClient(object):
|
||||
|
||||
|
||||
class BaseApi(object):
|
||||
|
||||
api_client: ApiClient
|
||||
|
||||
def __init__(self, api_client=None):
|
||||
|
||||
@ -204,12 +204,9 @@ from knext.rest.models.builder.pipeline.config.operator_predicting_config import
|
||||
OperatorPredictingConfig,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.predicting_config import PredictingConfig
|
||||
from knext.rest.models.builder.pipeline.config.new_instance_fusing_config import (
|
||||
NewInstanceFusingConfig,
|
||||
from knext.rest.models.builder.pipeline.config.overwrite_fusing_config import (
|
||||
OverwriteFusingConfig,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.spg_type_mapping_node_configs import (
|
||||
SpgTypeMappingNodeConfigs,
|
||||
)
|
||||
from knext.rest.models.builder.pipeline.config.not_import_fusing_config import (
|
||||
NotImportFusingConfig,
|
||||
)
|
||||
|
||||
@ -46,12 +46,6 @@ class BaseFusingConfig(object):
|
||||
|
||||
attribute_map = {"strategy_type": "strategyType", "fusing_type": "fusingType"}
|
||||
|
||||
discriminator_value_class_map = {
|
||||
"OPERATOR": "OperatorFusingConfig",
|
||||
"NEW_INSTANCE": "NewInstanceFusingConfig",
|
||||
"NOT_IMPORT": "NotImportFusingConfig",
|
||||
}
|
||||
|
||||
def __init__(
|
||||
self, strategy_type="FUSING", fusing_type=None, local_vars_configuration=None
|
||||
): # noqa: E501
|
||||
@ -129,7 +123,7 @@ class BaseFusingConfig(object):
|
||||
raise ValueError(
|
||||
"Invalid value for `fusing_type`, must not be `None`"
|
||||
) # noqa: E501
|
||||
allowed_values = ["OPERATOR", "NEW_INSTANCE", "NOT_IMPORT"] # noqa: E501
|
||||
allowed_values = ["OPERATOR", "OVERWRITE"] # noqa: E501
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation
|
||||
and fusing_type not in allowed_values
|
||||
|
||||
@ -1,188 +0,0 @@
|
||||
# coding: utf-8
|
||||
# Copyright 2023 Ant Group CO., Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
knext
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from knext.rest.configuration import Configuration
|
||||
|
||||
|
||||
class NewInstanceFusingConfig(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
"""
|
||||
Attributes:
|
||||
openapi_types (dict): The key is attribute name
|
||||
and the value is attribute type.
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
openapi_types = {"strategy_type": "str", "fusing_type": "str"}
|
||||
|
||||
attribute_map = {"strategy_type": "strategyType", "fusing_type": "fusingType"}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
strategy_type="FUSING",
|
||||
fusing_type="NEW_INSTANCE",
|
||||
local_vars_configuration=None,
|
||||
): # noqa: E501
|
||||
"""NewInstanceFusingConfig - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
|
||||
self._strategy_type = None
|
||||
self._fusing_type = None
|
||||
self.discriminator = fusing_type
|
||||
|
||||
self.strategy_type = strategy_type
|
||||
self.fusing_type = fusing_type
|
||||
|
||||
@property
|
||||
def strategy_type(self):
|
||||
"""Gets the strategy_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
|
||||
|
||||
:return: The strategy_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._strategy_type
|
||||
|
||||
@strategy_type.setter
|
||||
def strategy_type(self, strategy_type):
|
||||
"""Sets the strategy_type of this NewInstanceFusingConfig.
|
||||
|
||||
|
||||
:param strategy_type: The strategy_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation
|
||||
and strategy_type is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `strategy_type`, must not be `None`"
|
||||
) # noqa: E501
|
||||
allowed_values = ["LINKING", "FUSING", "PREDICTING"] # noqa: E501
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation
|
||||
and strategy_type not in allowed_values
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `strategy_type` ({0}), must be one of {1}".format( # noqa: E501
|
||||
strategy_type, allowed_values
|
||||
)
|
||||
)
|
||||
|
||||
self._strategy_type = strategy_type
|
||||
|
||||
@property
|
||||
def fusing_type(self):
|
||||
"""Gets the fusing_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
|
||||
|
||||
:return: The fusing_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._fusing_type
|
||||
|
||||
@fusing_type.setter
|
||||
def fusing_type(self, fusing_type):
|
||||
"""Sets the fusing_type of this NewInstanceFusingConfig.
|
||||
|
||||
|
||||
:param fusing_type: The fusing_type of this NewInstanceFusingConfig. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation and fusing_type is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `fusing_type`, must not be `None`"
|
||||
) # noqa: E501
|
||||
allowed_values = ["OPERATOR", "NEW_INSTANCE"] # noqa: E501
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation
|
||||
and fusing_type not in allowed_values
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `fusing_type` ({0}), must be one of {1}".format( # noqa: E501
|
||||
fusing_type, allowed_values
|
||||
)
|
||||
)
|
||||
|
||||
self._fusing_type = fusing_type
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.openapi_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(
|
||||
map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)
|
||||
)
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(
|
||||
map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict")
|
||||
else item,
|
||||
value.items(),
|
||||
)
|
||||
)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, NewInstanceFusingConfig):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, NewInstanceFusingConfig):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
||||
@ -28,7 +28,7 @@ import six
|
||||
from knext.rest.configuration import Configuration
|
||||
|
||||
|
||||
class NotImportFusingConfig(object):
|
||||
class OverwriteFusingConfig(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
@ -49,10 +49,10 @@ class NotImportFusingConfig(object):
|
||||
def __init__(
|
||||
self,
|
||||
strategy_type="FUSING",
|
||||
fusing_type="NOT_IMPORT",
|
||||
fusing_type="OVERWRITE",
|
||||
local_vars_configuration=None,
|
||||
): # noqa: E501
|
||||
"""NotImportFusingConfig - a model defined in OpenAPI""" # noqa: E501
|
||||
"""OverwriteFusingConfig - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
@ -66,20 +66,20 @@ class NotImportFusingConfig(object):
|
||||
|
||||
@property
|
||||
def strategy_type(self):
|
||||
"""Gets the strategy_type of this NotImportFusingConfig. # noqa: E501
|
||||
"""Gets the strategy_type of this OverwriteFusingConfig. # noqa: E501
|
||||
|
||||
|
||||
:return: The strategy_type of this NotImportFusingConfig. # noqa: E501
|
||||
:return: The strategy_type of this OverwriteFusingConfig. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._strategy_type
|
||||
|
||||
@strategy_type.setter
|
||||
def strategy_type(self, strategy_type):
|
||||
"""Sets the strategy_type of this NotImportFusingConfig.
|
||||
"""Sets the strategy_type of this OverwriteFusingConfig.
|
||||
|
||||
|
||||
:param strategy_type: The strategy_type of this NotImportFusingConfig. # noqa: E501
|
||||
:param strategy_type: The strategy_type of this OverwriteFusingConfig. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
if (
|
||||
@ -104,20 +104,20 @@ class NotImportFusingConfig(object):
|
||||
|
||||
@property
|
||||
def fusing_type(self):
|
||||
"""Gets the fusing_type of this NotImportFusingConfig. # noqa: E501
|
||||
"""Gets the fusing_type of this OverwriteFusingConfig. # noqa: E501
|
||||
|
||||
|
||||
:return: The fusing_type of this NotImportFusingConfig. # noqa: E501
|
||||
:return: The fusing_type of this OverwriteFusingConfig. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._fusing_type
|
||||
|
||||
@fusing_type.setter
|
||||
def fusing_type(self, fusing_type):
|
||||
"""Sets the fusing_type of this NotImportFusingConfig.
|
||||
"""Sets the fusing_type of this OverwriteFusingConfig.
|
||||
|
||||
|
||||
:param fusing_type: The fusing_type of this NotImportFusingConfig. # noqa: E501
|
||||
:param fusing_type: The fusing_type of this OverwriteFusingConfig. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
if (
|
||||
@ -126,7 +126,7 @@ class NotImportFusingConfig(object):
|
||||
raise ValueError(
|
||||
"Invalid value for `fusing_type`, must not be `None`"
|
||||
) # noqa: E501
|
||||
allowed_values = ["OPERATOR", "NEW_INSTANCE", "NOT_IMPORT"] # noqa: E501
|
||||
allowed_values = ["OPERATOR", "OVERWRITE"] # noqa: E501
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation
|
||||
and fusing_type not in allowed_values
|
||||
@ -175,14 +175,14 @@ class NotImportFusingConfig(object):
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, NotImportFusingConfig):
|
||||
if not isinstance(other, OverwriteFusingConfig):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, NotImportFusingConfig):
|
||||
if not isinstance(other, OverwriteFusingConfig):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
||||
@ -41,6 +41,7 @@ __package_name__ = "{package_name}"
|
||||
__version__ = "{version}"
|
||||
|
||||
from knext.common.env import init_env
|
||||
|
||||
init_env()
|
||||
"""
|
||||
wf.write(content)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user