fission-workflows icon indicating copy to clipboard operation
fission-workflows copied to clipboard

Nested functions

Open vishal-biyani opened this issue 6 years ago • 0 comments

Nested functions can be confusing and unclear to a new user. For example I wanted to run a if check on the output of a foreach - so I try to use if inside foreach as shown in following code"

  DataSplitter:
    run: foreach
    inputs:
      foreach: "{ output('DataProducer') }"
      do:
        run: if
        inputs: 
          if: "{ task().Inputs._item.availableSeats > 3 }"
          then:
            run: whalesay
            inputs:
              body: "{ task().Inputs._item.availableSeats }"
          else:
            run: noop
            inputs: "{ task().Inputs._item }"        
    requires:
    - DataProducer

So I expect that based on the logic, a noop or whalesay operation will be invoked, but the output of everything below inputs of the foreach is emitted as a text output.

[{"inputs":{"availableSeats":2,"carNumberPlate":"MOB-PDX","carPoolOwner":"MARTIN"},"run":"noop"},
{"inputs":{"availableSeats":3,"carNumberPlate":"THE-JON","carPoolOwner":"TIFFANY"},"run":"noop"},
{"inputs":{"availableSeats":3,"carNumberPlate":"MOB-PDX","carPoolOwner":"LINUS"},"run":"noop"},
{"inputs":{"body":4},"run":"whalesay"},{"inputs":{"body":4},"run":"whalesay"}]

The limitations of nested functions should be called out clearly or an example of nested function should be provided.

In this case, since nested if does not work, the user has to write a small function and do same if check and then pass on the data.

vishal-biyani avatar Sep 03 '18 05:09 vishal-biyani