refactor(api/core/workflow/nodes/base_node.py): Update extract_variable_selector_to_variable_mapping method signature. (#6733)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2024-07-27 14:43:25 +08:00 committed by GitHub
parent 90d2c01218
commit b6c3010f02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 13 deletions

View File

@ -115,7 +115,7 @@ class BaseNode(ABC):
)
@classmethod
def extract_variable_selector_to_variable_mapping(cls, config: dict) -> dict[str, list[str]]:
def extract_variable_selector_to_variable_mapping(cls, config: dict):
"""
Extract variable selector to variable mapping
:param config: node config
@ -125,14 +125,13 @@ class BaseNode(ABC):
return cls._extract_variable_selector_to_variable_mapping(node_data)
@classmethod
@abstractmethod
def _extract_variable_selector_to_variable_mapping(cls, node_data: BaseNodeData) -> dict[str, list[str]]:
def _extract_variable_selector_to_variable_mapping(cls, node_data: BaseNodeData) -> Mapping[str, Sequence[str]]:
"""
Extract variable selector to variable mapping
:param node_data: node data
:return:
"""
raise NotImplementedError
return {}
@classmethod
def get_default_config(cls, filters: Optional[dict] = None) -> dict:

View File

@ -389,11 +389,10 @@ class WorkflowEngineManager:
environment_variables=workflow.environment_variables,
)
if node_cls is None:
raise ValueError('Node class not found')
# variable selector to variable mapping
try:
variable_mapping = node_cls.extract_variable_selector_to_variable_mapping(node_config)
except NotImplementedError:
variable_mapping = {}
self._mapping_user_inputs_to_variable_pool(
variable_mapping=variable_mapping,
@ -473,10 +472,9 @@ class WorkflowEngineManager:
for node_config in iteration_nested_nodes:
# mapping user inputs to variable pool
node_cls = node_classes.get(NodeType.value_of(node_config.get('data', {}).get('type')))
try:
if node_cls is None:
raise ValueError('Node class not found')
variable_mapping = node_cls.extract_variable_selector_to_variable_mapping(node_config)
except NotImplementedError:
variable_mapping = {}
# remove iteration variables
variable_mapping = {
@ -942,7 +940,7 @@ class WorkflowEngineManager:
return new_value
def _mapping_user_inputs_to_variable_pool(self,
variable_mapping: dict,
variable_mapping: Mapping[str, Sequence[str]],
user_inputs: dict,
variable_pool: VariablePool,
tenant_id: str,