Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested functions #196

Open
vishal-biyani opened this issue Sep 3, 2018 · 0 comments
Open

Nested functions #196

vishal-biyani opened this issue Sep 3, 2018 · 0 comments

Comments

@vishal-biyani
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants