Quick fix for taskoutput change bug in forloopblock (#323)

This commit is contained in:
Kerem Yilmaz
2024-05-15 00:16:15 -07:00
committed by GitHub
parent cc50b81a4d
commit 479186bbef
2 changed files with 18 additions and 2 deletions

View File

@@ -232,6 +232,11 @@ class WorkflowRunContext:
and isinstance(parameter.source, OutputParameter)
and parameter.source.key == output_parameter.key
):
value = (
value["extracted_information"]
if isinstance(value, dict) and "extracted_information" in value
else value
)
if parameter.value:
LOG.warning(
f"Context parameter {parameter.key} already has a value, overwriting",

View File

@@ -339,14 +339,25 @@ class ForLoopBlock(Block):
return context_parameters
def get_loop_over_parameter_values(self, workflow_run_context: WorkflowRunContext) -> list[Any]:
if isinstance(self.loop_over, WorkflowParameter) or isinstance(self.loop_over, OutputParameter):
if isinstance(self.loop_over, WorkflowParameter):
parameter_value = workflow_run_context.get_value(self.loop_over.key)
elif isinstance(self.loop_over, OutputParameter):
# If the output parameter is for a TaskBlock, it will be a TaskOutput object. We need to extract the
# value from the TaskOutput object's extracted_information field.
output_parameter_value = workflow_run_context.get_value(self.loop_over.key)
if isinstance(output_parameter_value, dict) and "extracted_information" in output_parameter_value:
parameter_value = output_parameter_value["extracted_information"]
else:
parameter_value = output_parameter_value
elif isinstance(self.loop_over, ContextParameter):
parameter_value = self.loop_over.value
if not parameter_value:
source_parameter_value = workflow_run_context.get_value(self.loop_over.source.key)
if isinstance(source_parameter_value, dict):
parameter_value = source_parameter_value.get(self.loop_over.key)
if "extracted_information" in source_parameter_value:
parameter_value = source_parameter_value["extracted_information"].get(self.loop_over.key)
else:
parameter_value = source_parameter_value.get(self.loop_over.key)
else:
raise ValueError("ContextParameter source value should be a dict")
else: