Task Queue¶
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:
- In list format, where each line represents a single task:
You can identify the status of each task as follows:
It is also possible to use the filters State, Automation, Runner, Task ID, Start date and End date to view specific tasks.
Task information¶
You can follow the information of a task in two ways:
- Clicking directly on the task name within the task card.
- Clicking the icon with three points in the task card's upper corner and selecting the option Info.
And through the list of tasks, it is possible to access the detailed information by clicking on the task ID:
You will be redirected to a page with detailed task information using any of the above. Being able to view:
General execution information¶
Where:
- State: Carries the info on the state of the task.
- Life Cycle: The lifetime of the task, from when it enters the queue until it completes.
- Queue Time: The time that remained in the execution queue.
- 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.
Task parameters¶
You can also visualize the parameters used in the task.
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:
- BotCity Maestro New Task feature via the orchestrator interface.
- BotCity CLI's task create command via command line.
- BotCity Maestro SDK via code.
- BotCity Maestro API via the API.
General information from the task queue, task, and runtime¶
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 . This button allows:
- Delete: Delete a task that is in the execution queue.
- Interrupt: Request the interruption of the task. Learn more about this functionality here.
- Terminate: Terminates the task forcing the execution to end.
- Restart: Restart a task marked as the test.
Note
- Tasks running only have actions
Interrupt
andTerminate
. - Tasks in the queue only have actions
Delete
andInterrupt
. - Only tasks defined as a test can reproduce the action
Restart
. - Finished tasks have no action available.
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¶
# Finishing the task successfully
maestro.finish_task(
task_id=execution.task_id,
status=AutomationTaskFinishStatus.SUCCESS,
message="Task Finished with Success."
)
// Finishing the task successfully
maestro.finishTask(botExecution.getTaskId(), "Task Finished with Success.", FinishStatus.SUCCESS);
// 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"
)
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."
)
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);
} 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.