fix: update variable completeness check to allow None parameter (#16389)

This commit is contained in:
buua436
2026-06-29 10:51:57 +08:00
committed by GitHub
parent 61ac1c1dff
commit b6dbb2f71e

View File

@@ -40,6 +40,7 @@ class VariableAssignerParam(ComponentParamBase):
class VariableAssigner(ComponentBase,ABC): class VariableAssigner(ComponentBase,ABC):
component_name = "VariableAssigner" component_name = "VariableAssigner"
_NO_PARAMETER_OPERATORS = {"clear", "remove_first", "remove_last"}
@timeout(int(os.environ.get("COMPONENT_EXEC_TIMEOUT", 10*60))) @timeout(int(os.environ.get("COMPONENT_EXEC_TIMEOUT", 10*60)))
def _invoke(self, **kwargs): def _invoke(self, **kwargs):
@@ -47,11 +48,14 @@ class VariableAssigner(ComponentBase,ABC):
return return
else: else:
for item in self._param.variables: for item in self._param.variables:
if any([not item.get("variable"), not item.get("operator"), not item.get("parameter")]): variable = item.get("variable")
operator = item.get("operator")
parameter = item.get("parameter")
if any([not variable, not operator]):
raise ValueError("Variable is not complete.")
if operator not in self._NO_PARAMETER_OPERATORS and parameter is None:
raise ValueError("Variable is not complete.") raise ValueError("Variable is not complete.")
variable=item["variable"]
operator=item["operator"]
parameter=item["parameter"]
variable_value=self._canvas.get_variable_value(variable) variable_value=self._canvas.get_variable_value(variable)
new_variable=self._operate(variable_value,operator,parameter) new_variable=self._operate(variable_value,operator,parameter)
self._canvas.set_variable_value(variable, new_variable) self._canvas.set_variable_value(variable, new_variable)