Skip to content

First Steps

1. Import

Start with the basics, which is importing the necessary classes and methods. (DotFlow, action)

from dotflow import DotFlow, action

# Code below omitted πŸ‘‡
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

2. Callback function

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

# Code above omitted πŸ‘†

def my_callback(*args, **kwargs):
    print(args, kwargs)

# Code below omitted πŸ‘‡
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

3. Task function

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.

# Code above omitted πŸ‘†

@action
def my_task():
    print("task")

# Code below omitted πŸ‘‡
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

4. DotFlow Class

Instantiate the DotFlow class in a workflow variable to be used in the following steps. More details.

# Code above omitted πŸ‘†

workflow = DotFlow()

# Code below omitted πŸ‘‡
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

5. Add Task

Now, simply add the my_task 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

# Code above omitted πŸ‘†

workflow.task.add(step=my_task, callback=my_callback)

# Code below omitted πŸ‘‡
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

6. Start

Finally, just execute the workflow with the following code snippet. More details

# Code above omitted πŸ‘†

workflow.start()
πŸ‘€ Full file preview
from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()

Full Code

The simplest file could look like this:

from dotflow import DotFlow, action


def my_callback(*args, **kwargs):
    print(args, kwargs)


@action
def my_task():
    print("task")


workflow = DotFlow()
workflow.task.add(step=my_task, callback=my_callback)
workflow.start()