-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add control flow / utility functions to the workflow engine #135
Conversation
I'm pretty excited about this one 😀 I'd love to see some examples. |
pkg/fnenv/native/builtin/foreach.go
Outdated
) | ||
|
||
// FunctionForeach is a control flow construct to execute a certain task for each element in the provided input. | ||
// The tasks are executed in parallel. Foreach does not gather or store the outputs of the tasks in any way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the recommendation to users for how to deal with task output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #135 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how that answers the question? If there is no output collected, what do we recommend to the users who want to process a set of data in an array?
pkg/fnenv/native/builtin/foreach.go
Outdated
// for: [], | ||
// do: | ||
// run: noop | ||
// inputs: "{$.???}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ??? a placeholder or the actual syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, not done with that one yet :)
pkg/fnenv/native/builtin/foreach.go
Outdated
// The tasks are executed in parallel. Foreach does not gather or store the outputs of the tasks in any way. | ||
// | ||
// For example: | ||
// foo: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will $.Tasks.foo.Output
be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not done yet, but the idea was for foreach that there is no output (see description above this example). I am open to suggestions though :)
8819dad
to
851fe31
Compare
Bringing the output discussion into the comments here. I think we need to give users some way to run "map", i.e. run a task on each element of an array and collect the output into another array. That doesn't have to be a builtin, but there needs to be a way for the user to implement that. |
cc @MadisonHope comments welcome |
@erwinvaneyk I see lots of code commits, but can we have a discussion before merging this to make sure these new builtins actually solve the problem they're intended to solve? |
@soamvasani sure, I am not merging this until your and Madison's 👍 |
Updating from slack conversation, @erwinvaneyk's adding a flag to collect output of tasks in |
I run this branch to solve some other problems on 0.2 and I couldn't make workflow send body as json to function (it does on 0.2 successfully and flask can parse request and return json response without any problem). This is what I did extra for forcing to pass json but still not working:
It sends binary value after whatever I do: |
As I understand from code, currently it is just passing value of default (body) without parsing it to json or something. This happens if you pass key-value to the default like:
|
Hey @thenamly - I have been working on this problem offline. the content type (indeed one of the last issues that needs to be resolved before 0.3.0 release). Same goes for the forcing of the content-type. Will update the branch later today. |
e03b51a
to
b29a867
Compare
These includde - foreach; a task that allows looping over an array of values and execute a specific task. - fail: a task that allways fails, allowing users to shortcircuit workflow execution. - http; a utility task to execute simple HTTP calls - switch; a task that executes outputs a value based on the output of an expression. Similar to switch constructs in many languages. - while;; a task that keeps executing a task until a specific condition is true.
Before, structs could not be parsed into the typedvalues format, which lead to those vals to be returned as null making tasks unavailable
This PR adds the following functions to the workflow engine:
foreach
http
switch
while
fail
Additionally, this PR...
fission version
commandBefore merging:
foreach
+ examplewhile