Configure the robot commands to point to the tasks

Implementing your robot in small increments and testing it often is important. We know our robot needs to do 2 things: produce and consume. We are going to define 2 tasks that do exactly that:

from robocorp.tasks import task @task def produce_traffic_data(): """ Inhuman Insurance, Inc. Artificial Intelligence System automation. Produces traffic data work items. """ print("produce") @task def consume_traffic_data(): """ Inhuman Insurance, Inc. Artificial Intelligence System automation. Consumes traffic data work items. """ print("consume")

You try running the robot and your robot, surprinsingly, passes:

Collecting tasks from: tasks.py ======================== Running: produce_traffic_data ========================= produce produce_traffic_data status: PASS ================================================================================ ======================== Running: consume_traffic_data ========================= consume consume_traffic_data status: PASS

This is the first time you have more than one @task defined and you want to understand how this works. Both of your tasks ran, one after the other. You open the robot.yaml file.

tasks: Minimal Task: shell: python -m robocorp.tasks run tasks.py

You notice a general command that runs everything it finds in tasks.py file. You want a finer control so you modify it so that it points to the tasks that you previously defined. You create two entries, each with it's descriptive name for your tasks.

tasks: Produce data: shell: python -m robocorp.tasks run tasks.py -t produce_traffic_data Consume data: shell: python -m robocorp.tasks run tasks.py -t consume_traffic_data

The -t flag shows that we refer to a @task method followed by the actual name of the method. This way each task runs under it's specific and suggestive name:

You rerun the robot, and the Robocorp extension asks what task you want to run. You run both of the tasks, and they (should) pass. Great!