This is a very simple library that is still in the early stages of development. The main goal of this tool is to create a simple and secure workflow for executing any type of task. The library's API design was made to make it easy to add tasks and control their execution. To keep it simple, just instantiate the DotFlow
class, use the add
method, and the start
method to begin execution.
Start with the basics here.
Click to expand
We use GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them. If you need anything, I ask you to please follow our templates for opening issues or discussions.
- π Bug Report
- π Documentation Issue
- π Feature Request
- π¬ General Question
To install Dotflow
, run the following command from the command line:
With Pip
pip install dotflow
With Poetry
poetry add dotflow
The simplest file could look like this:
from dotflow import DotFlow, action
def my_callback(*args, **kwargs):
print(args, kwargs)
@action
def my_task_x():
print("task")
@action(retry=5)
def my_task_y():
print("task")
workflow = DotFlow()
workflow.task.add(step=my_task_x, callback=my_callback)
workflow.task.add(step=my_task_y, callback=my_callback)
workflow.start()
Start with the basics, which is importing the necessary classes and methods. (DotFlow, action)
from dotflow import DotFlow, action
Create a my_callback
function to receive execution information of a task. It is not necessary
to include this function, as you will still have a report at the end of the execution in the instantiated object of the DotFlow
class. This my_callback
function is only needed if you need to do something after the execution of the task, for example: sending a message to someone, making a phone call, or sending a letter. More details
def my_callback(*args, **kwargs):
print(args, kwargs)
Now, create the function responsible for executing your task. It's very simple; just use the action decorator above the function, and that's itβyou've created a task. If necessary, you can also add the parameter called retry
to set the maximum number of execution attempts if the function fails. More details
@action(retry=5)
def my_task_x():
print("task")
Instantiate the DotFlow class in a workflow
variable to be used in the following steps. More details.
workflow = DotFlow()
Now, simply add the my_task_x
and my_callback
functions you created earlier to the workflow using the code below. This process is necessary to define which tasks will be executed and the order in which they will run. The execution order follows the sequence in which they were added to the workflow. More details
- Adding one step at a time:
workflow.task.add(step=my_task_x, callback=my_callback)
workflow.task.add(step=my_task_y, callback=my_callback)
- Adding multiple steps at the same time:
workflow.task.add(step=[my_task_x, my_task_y], callback=my_callback)
- Adding a step with the module path:
workflow.task.add(step="module.task.my_task_x", callback=my_callback)
Finally, just execute the workflow with the following code snippet. More details
workflow.start()
dotflow start --step examples.cli_with_mode.simple_step
dotflow start --step examples.cli_with_initial_context.simple_step --initial-context abc
dotflow start --step examples.cli_with_callback.simple_step --callback examples.cli_with_callback.callback
dotflow start --step examples.cli_with_mode.simple_step --mode sequential
dotflow start --step examples.cli_with_mode.simple_step --mode background
- βοΈ FEATURE
- π PEP8
- π ISSUE
- πͺ² BUG
- π DOCS
- π¦ PyPI
- β€οΈοΈ TEST
- β¬οΈ CI/CD
β οΈ SECURITY
This project is licensed under the terms of the MIT License.