Skip to content

Tasks

The Task Queue shows tasks in execution, ready to be executed, and finished.

Task queue visualization

You can view the task queue in two ways:

  • In card format, where each card represents a single task:

Card task queue

  • In list format, where each line represents a single task:

List task line

It is also possible to use the filters State, Repository, Automation, Runner, Task ID, Start date and End date to view specific tasks.

Task Filters

The task queue also has a Last Update column where you can see how long a task has been in the queue, being processed or completed. This functionality provides a clearer view of the time spent on each step.

Warning about offline Runners

If there are queued tasks associated with Runners that are offline, a warning will be displayed for you to review your allocated Runners.

This alert includes a direct link to the platform's Runners tab, where you can manage your workspace's Runners.

Customizing the task view

You can also customize the task view table according to your preferences.

Task Queue Custom View

When you select a filter type or column sort, this setting will be saved as the default. For more details, use the Customize task list view button.

Task Queue Custom View

Task information

Status

When creating a new task, it will initially have the status of In Queue; that is, it will wait until a Runner is available to execute it.

We can better understand the status that a task can take during its lifecycle as follows:

Task Status

In Queue: The task is waiting to be processed; at this point, it will be available to be executed by the Runner that has been linked to the automation process.

Running: The task was pulled for execution by Runner and is in the processing phase.

Finished: The task processing was completed successfully.

Failed: The task processing ended with failure.

Partially Completed: Task processing has been partially completed. For example, think of a process where some items were processed successfully and others were not processed correctly.

Canceled: The task execution was canceled before it was pulled for execution.

Tip

Task finish statuses can be reported directly through the automation code, based on the business rules of your process.

General execution information

You can access specific information about a task by clicking directly on the name of the automation, within the task card.

info-card

Using the list format view, you can access detailed information by clicking on the task ID:

Lista Tarefa info

You will be redirected to a page with detailed task information using any of the above. Being able to view:

Generals Infos

Where:

  • State: Carries the info on the state of the task.
  • Processed items: Number of items successfully processed by the task.
  • Failed items: Number of failed items processed by the task.
  • Execution: The task execution time, after leaving the execution queue.
  • Runner: The Runner responsible for executing the task.

Task finishing message

You can view the task-finishing message. If an error occurs during environment preparation or code execution, this information will be displayed in the finalization message.

You can also set a custom finish message. See more details about how to finish a task in Maestro in the following steps.

Message finish

Task parameters

You can also visualize the parameters used in the task.

Parameters

You will find the user-defined execution parameters when creating a new task.

Tip

The definition of the parameters set is done by developers when creating an automation process.

Learn more about how to create a task with or without parameters using:

General information from the task queue, task, and runtime

Task Queue Info

Where:

  • Queue control: It has task queue control information such as task priority, minimum execution date, and infos if the task has been interrupted or terminated by the Maestro UI.

  • Task summary: It has information from the task, such as ID, label, the user that started the task, and whether it is a test task.

  • Runtime: It has execution information, such as the Runner that performed the task and the date and time the task was created, started, and finished.

Task actions

On the task information screen, you will find the button Actions. This button allows:

  • Delete: Delete a task that is in the execution queue.
  • Request stop: Request the interruption of the task. Learn more about this functionality here.
  • Force to stop: Terminates the task forcing the execution to end.
  • Restart: Restart a task marked as the test.
  • Cancel: Cancels the execution of a previously created task in the queue.
  • Duplicate: Creates a canceled or previously executed task in the queue with the same assignments.

Warning

  • Tasks running only have actions Request stop and Force to stop.
  • Tasks in the queue only have actions Delete and Cancel.
  • Only tasks defined as a test can reproduce the action Restart.
  • Finished or canceled tasks only have the Duplicate action.

How to finish a task using the Maestro SDK

By default, when running a task for the first time without using any integration with Maestro, the task will finish with the status of Failed.

This happens because we must define the instructions to finish the task in the code and report the desired end status to Maestro.

Using the Maestro SDK in your automation code, you can easily finish tasks in Maestro.

Installation

If you don't have the dependency installed yet, just follow these instructions:

pip install botcity-maestro-sdk

Important

In addition to installing, remember to include the dependency in the bot's requirements.txt file.

<repositories>
    <repository>
        <id>nexus-botcity-public</id>
        <url>https://devtools.botcity.dev:8081/repository/botcity-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <!-- Your other dependencies -->
    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>maestro-sdk</artifactId>
        <version>2.0.3</version>
    </dependency>
</dependencies>
npm i @botcity/botcity-maestro-sdk
npm i @botcity/botcity-maestro-sdk

Importing the SDK

After installation, import the dependency and instantiate the Maestro SDK:

# Import for integration with BotCity Maestro SDK
from botcity.maestro import *

# Disable errors if we are not connected to Maestro
BotMaestroSDK.RAISE_NOT_CONNECTED = False

# Instantiating the Maestro SDK
maestro = BotMaestroSDK.from_sys_args()
# Fetching the details of the current task being executed
execution = maestro.get_execution()
// Import for integration with BotCity Maestro SDK
import dev.botcity.maestro_sdk.*;
...

public void action(BotExecution botExecution) {

    try {
        // Instantiating the Maestro SDK
        BotMaestroSDK maestro = new BotMaestroSDK();
        maestro.login(botExecution);
    ...
// Import for integration with BotCity Maestro SDK
const { BotMaestroSdk } = require('@botcity/botcity-maestro-sdk')

// Getting parameters passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args

// Login with information from the Dev. Environment page
const maestro = new BotMaestroSdk()
maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

// Fetching the details of the current task being executed
const executionTask = await maestro.getTask(taskid)
// Import for integration with BotCity Maestro SDK
import { BotMaestroSdk } from '@botcity/botcity-maestro-sdk'

// Getting parameters passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args

// Login with information from the Dev. Environment page
const maestro: BotMaestroSdk = new BotMaestroSdk()
maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

// Fetching the details of the current task being executed
const executionTask: Task = await maestro.getTask(taskid)

Finishing a task and reporting data

In addition to reporting the finish status of a task, we can also report additional data related to the items that were processed during execution.

maestro.finish_task(
    task_id=execution.task_id,
    status=AutomationTaskFinishStatus.SUCCESS,
    message="Task Finished with Success.",
    total_items=100, # Total number of items processed
    processed_items=90, # Number of items processed successfully
    failed_items=10 # Number of items processed with failure
)
maestro.finishTask(
    botExecution.getTaskId(),
    "Task Finished with Success.",
    FinishStatus.SUCCESS,
    100, // Total number of items processed
    90, // Number of items processed successfully
    10 // Number of items processed with failure
);
// Finishing the task successfully
await maestro.finishtTask(
    executionTask.id,
    "Task finished with Success.",
    "SUCCESS"
)
// Finishing the task successfully
await maestro.finishtTask(
    executionTask.id,
    "Task finished with Success.",
    "SUCCESS"
)

Info

The feature of reporting data is also part of the BotCity Insights, which is a module dedicated to reporting and displaying data related to your RPA initiative.

The step of reporting data in the automation code is essential for high-level information to be generated.

See more details about this module by accessing the BotCity Insights documentation.

Complete code

from botcity.core import DesktopBot
from botcity.maestro import *

# Disable errors if we are not connected to Maestro
BotMaestroSDK.RAISE_NOT_CONNECTED = False

def main():
    maestro = BotMaestroSDK.from_sys_args()
    execution = maestro.get_execution()

    bot = DesktopBot()
    # Implement here your logic...
    ...

    # Finishing the task successfully
    maestro.finish_task(
        task_id=execution.task_id,
        status=AutomationTaskFinishStatus.SUCCESS,
        message="Task Finished with Success.",
        total_items=100, # Total number of items processed
        processed_items=90, # Number of items processed successfully
        failed_items=10 # Number of items processed with failure
    )

def not_found(label):
    print(f"Element not found: {label}")

if __name__ == '__main__':
    main()
import dev.botcity.framework.bot.DesktopBot;
import dev.botcity.maestro_sdk.BotExecutor;
import dev.botcity.maestro_sdk.BotMaestroSDK;
import dev.botcity.maestro_sdk.model.AutomationTask.FinishStatus;
import dev.botcity.maestro_sdk.runner.BotExecution;
import dev.botcity.maestro_sdk.runner.RunnableAgent;

public class FirstBot extends DesktopBot implements RunnableAgent
{
    public FirstBot() {
        try {
            setResourceClassLoader(this.getClass().getClassLoader());
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void action(BotExecution botExecution) {

        try {
            BotMaestroSDK maestro = new BotMaestroSDK();
            maestro.login(botExecution);

            // Implement here your logic...

            // Finishing the task successfully
            maestro.finishTask(
                botExecution.getTaskId(),
                "Task Finished with Success.",
                FinishStatus.SUCCESS,
                100, // Total number of items processed
                90, // Number of items processed successfully
                10 // Number of items processed with failure
            );

        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    private void notFound(String label) {
        System.out.println("Element not found: "+label);
    }

    public static void main(String[] args) {
        BotExecutor.run(new FirstBot(), args);
    }
}
const main = async () => {
    const { BotMaestroSdk } = require('@botcity/botcity-maestro-sdk')

    const args = process.argv.slice(2)
    const [server, taskid, token] = args

    const maestro = new BotMaestroSdk()
    maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

    const executionTask = await maestro.getTask(taskid)

    // Finishing the task successfully
    await maestro.finishtTask(
        executionTask.id,
        "Task finished with Success.",
        "SUCCESS"
    )
}

main()
const main = async () => {
    import { BotMaestroSdk } from '@botcity/botcity-maestro-sdk'

    const args = process.argv.slice(2)
    const [server, taskid, token] = args

    const maestro: BotMaestroSdk = new BotMaestroSdk()
    maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

    const executionTask: Task = await maestro.getTask(taskid)

    // Finishing the task successfully
    await maestro.finishtTask(
        executionTask.id,
        "Task finished with Success.",
        "SUCCESS"
    )
}

main()

Tip

Look at the other operations we can do with tasks using the BotCity Maestro SDK and BotCity Maestro API.