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

Conditional flows. Understanding the number of steps to be executed. #99

Closed
joseconstela opened this issue Dec 2, 2020 · 4 comments
Closed

Comments

@joseconstela
Copy link
Member

joseconstela commented Dec 2, 2020

Issuehunt badges

As the implementation of conditional steps is reaching to its end, I've encountered a good number of use cases and situations where Tideflow needs to change how it's calculating if the execution of a workflow should be considered as completed.

You can check the progress of the conditional steps implementation in #85.

Until now this was calculated based on the number of steps in the flow, and the number of completed tasks. But as per the conditional steps implementation, Tideflow needs your help and expertise to update its logic to match the new requirements.

Please be aware that this issue description might change in the upcoming days as new cases might come to light.


Number of steps meant to be executed in a flow with conditional steps

Hello!

I'm looking for someone to write some javascript code (for both the server via NodeJS and for the browser). It must be capable of understanding how many steps does a flow have, and how many are meant to be executed - as some steps represents conditions.

Whatever code you write (let's call it "your function") must be able to intake two different parameters.

Help for implementation:

Diagrams, code snippets, images, etc

examples-for-tideflow-99.zip

Deliverables

Deliverables are:

  1. Efficient javascript code that runs both in server side - via NodeJS and modern browsers.
  2. Code can be used for any flow - not only the ones attached to this work request.
  3. Unit Test cases in mocha (100% code coverage)

You can either provide the solution as a zip file or upload it as brand new files at https://github.com/tideflow-io/tideflow/tree/joseconstela/issue85/imports/queue/server - this is: a branch you create out of joseconstela/issue85.

Your function

The first parameter

The "flow diagram" - is a json representation of the flow. Including its trigger, list of steps, how they are connected to each other, and how are conditional steps outputs connected. This "flow diagram" have the following format:

```JSON
{
  trigger: {
     outputs: [ { stepIndex: 1 } ]
  },
  steps: [
    { type: "abc", outputs: [ { reason: "step", stepIndex: 2 } ] },  /* 0 */
    { type: "abc", outputs: [ { reason: "step", stepIndex: 2 } ] },  /* 1 */
    { type: 'conditions', outputs: [                                 /* 2 */
      { reason: "condition-false", stepIndex: 3 },
      { reason: "condition-true", stepIndex: 4 } 
    ] },
    { type: "abc", outputs: [] },                                    /* 3 */
    { type: "abc", outputs: [] }                                     /* 4 */
  ]
}
```
  • The "trigger" is the initial task that initiates the flow's execution.
  • The "steps" are all other tasks that are meant to be executed (as long as their preceding tasks are available).
  • The "steps.$.type" string is only useful for your function if its value is "conditions". In this case you will expect different types of outputs.
  • The "steps.$.outputs" represents to wihch tasks is a given task connected.
  • The "steps.$.outputs.$.reason" represents why such connection is stablished.
  • The "steps.$.outputs.$.stepIndex" represents the index (of the "steps" array) that the task is connected to.

The second parameter

OPTIONAL - the "steps results" - is an array that contains the list of executed steps - at any given time. It tells your function the list of conditions, and if they passed or not. An example for this parameter could be:

```JSON
[
  { stepIndex: 2, pass: false },
  { stepIndex: 4, pass: true },
  { stepIndex: 9, pass: false }
]
```

What this tells your function is that the conditions of the 3rd and 10th steps did not passed, and the 5th step condition did passed.

Your function's result

Your function's result must be - when possible - the number of total steps in the flow, but also (if it have any conditions) the number of steps that are meant to be executed, given the list of steps results. But also to check for some cases that could jeopardize the correct behaviour of a flow execution.

Some example outputs for your function could be:

A flow that does not have any conditions

We simply expect the number of steps in total

```JSON
{
  steps: 4
}
```

You can find examples for this flows diagrams in:

  • simple.js

A flow that does have conditions

The behaviour of your function in this case will vary depending on the content of the second parameter - the "steps results" array.

For example, if the "steps result" array is empty, them the result is expected to contain the list of total steps (as in flow.steps.length) and executionSteps as "unknown".

The reason behind the "unknown" value is that, as the flow does have some conditional steps, it's impossible for your function to know how many steps it will execute, as it has no clue if those conditions are met or not.

```JSON
{
  steps: 4,
  executionSteps: "unknown"
}
```

And in case the "steps result" array is provided with condition(s) result(s), then executionSteps is meant to contain the number of tasks that could be executed - unless such number is "unknown" for the given "steps result" array.

You can find examples for this flows diagrams in:

  • complex-with-conditions.js
  • condition.js
  • conditions-no-results.js
  • conditions-only-one-result.js

In the case of a circular flow

Circular flows detection is already implemented: https://github.com/tideflow-io/tideflow/blob/joseconstela/issue85/imports/modules/flows/both/flow.js#L115

A circular flow is a flow diagram in which any of it steps could be executed more than once. Your function must throw an error in such case, as we don't want to execute flow steps in a loop :).

You can find examples for this flows diagrams in:

  • circular.js
  • circular-with-condition.js
  • circular-complex-with-conditions.js

IssueHunt Summary

Backers (Total: $0.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips

@issuehunt-oss
Copy link

issuehunt-oss bot commented Dec 2, 2020

@joseconstela has funded $140.00 to this issue.


@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Dec 2, 2020
@issuehunt-oss
Copy link

issuehunt-oss bot commented Dec 10, 2020

@joseconstela has cancelled funding for this issue.(Cancelled amount: $140.00) See it on IssueHunt

@issuehunt-oss issuehunt-oss bot removed the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Dec 10, 2020
@joseconstela
Copy link
Member Author

Ongoing solution on https://github.com/tideflow-io/puzzles_99

@joseconstela
Copy link
Member Author

All use cases are now implemented on https://github.com/tideflow-io/tideflow/tree/joseconstela/issue85

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

No branches or pull requests

1 participant