When using nested AdHoc Actions that use output transformations, the action result is only being transformed by the output of the action that is being called. Output transformations in nested actions are not processed.
If concat_twice is called, the output is "foo+bar and foo+bar"
So the expected output from nested_concat would be {"nested_concat": "foo+bar and foo+bar"}
But since the output transform of the called action is the only one that is executed, the output transform in the concat_twice action is skipped and the output is:
{"nested_concat": "foo+bar"}
The fix for this is to do the same traversal of nested actions in the _prepare_output() method that is already being done in the _prepare_input() method, except that the order is reversed so that the base action output transform is processed first, and the called action output transform is called last.
def _prepare_output(self, result):
# In case of error, we don't transform a result.
if not result.is_error():
for action_def in reversed(self.adhoc_action_defs): adhoc_action_spec = spec_parser.get_action_spec(action_def.spec)
transformer = adhoc_action_spec.get_output()
if transformer is not None: result = ml_actions.Result( data=expr.evaluate_recursively(transformer, result.data), error=result.error )
return result
When using nested AdHoc Actions that use output transformations, the action result is only being transformed by the output of the action that is being called. Output transformations in nested actions are not processed.
For example:
actions:
concat_twice:
base: std.echo
base-input:
output: "<% $.s1 %>+<% $.s2 %>"
input:
- s1: "a"
- s2
output: "<% $ %> and <% $ %>"
nested_concat: concat: '{{ _ }}'
base: my_wb.concat_twice
base-input:
s1: '{{ _.n1 }}'
s2: 'bar'
input:
- n1: 'foo'
output:
nested_
If concat_twice is called, the output is "foo+bar and foo+bar"
So the expected output from nested_concat would be {"nested_concat": "foo+bar and foo+bar"}
But since the output transform of the called action is the only one that is executed, the output transform in the concat_twice action is skipped and the output is:
{"nested_concat": "foo+bar"}
The fix for this is to do the same traversal of nested actions in the _prepare_output() method that is already being done in the _prepare_input() method, except that the order is reversed so that the base action output transform is processed first, and the called action output transform is called last.
def _prepare_ output( self, result): self.adhoc_ action_ defs):
adhoc_ action_ spec = spec_parser. get_action_ spec(action_ def.spec)
# In case of error, we don't transform a result.
if not result.is_error():
for action_def in reversed(
if transformer is not None:
result = ml_actions.Result(
data= expr.evaluate_ recursively( transformer, result.data),
error= result. error
)
return result