In the project root, run:
pip install .or
pip install taskflowor add this to your requirements.txt file:
taskflow @ git+ssh://[email protected]/Vectorworks/taskflow.git@v{tag}
If you are using a virtual environment, make sure to activate it before running the following commands.
To run tox locally you need only the dev requirements, which can be installed with:
pip install -e .[dev]or
pip install -r requirements-dev.txttaskflow is a simple workflow library, designed to be easily extended to support asynchronous distributed execution.
The logic is centered around Tasks. Tasks can be chained or executed in parallel. To execute the tasks in the correct order you will need to add the to a Flow object.
from taskflow import Flow, Task
flow = Flow(Task(func=lambda x: x * x, args=(5,)))
flow.run()
25To chain tasks, use the then method. This will make sure these tasks are executed in the correct order. Tasks passed in then will receive the previous tasks result as a parameter, alongside any explicit parameters.
from taskflow import Flow, Task
flow = Flow(
Task(
func=lambda x: x * x, args=(5,)
).then(
Task(func=lambda *args: sum(args), args=(10,))
)
)
flow.run()
35