Running robots in Robocorp Lab
Robocorp Lab provides multiple ways to run your robots. This article explains the different run modes.
The run environment
When you open or create a robot from the Robocorp Lab launch screen, a virtual Python environment is created for your robot (or updated, if the environment already exists). The environment setup is based on Conda:
Conda is an open-source package management system and environment management system that runs on Windows, macOS and Linux. Conda quickly installs, runs and updates packages and their dependencies. Conda easily creates, saves, loads and switches between environments on your local computer. - https://docs.conda.io/
The virtual environment keeps your robot and its dependencies isolated and separated from the other robots and dependencies on your system. This way you can control the exact versions of the dependencies you need for each of your robots.
How does Robocorp Lab know what dependencies to install for each robot?
When creating or updating the environment during the launch, Robocorp Lab reads the
conda.yaml file and includes the dependencies defined there to the environment. The same file is used to create an environment when running your robots with Robocorp Workforce Agent or Assistant, so it is important to keep the file updated when modifying dependencies.
Running the full robot in Notebook mode
tasks.robot file to open it in Notebook mode. You have many options for running your robot:
- Press the
>>icon in the Notebook toolbar and click
Shift-Command-Enter(macOS) and click
Restart Kernel and Run All Cells...from the main menu at the top and click
Robocorp Lab restarts the RobotKernel and runs all the cells in the Notebook, using the current Conda environment.
The Notebook run will automatically parse and use the
devdata/env.json file. Using this file, you can provide environment variables for your robot when doing local environment runs. When running in Robocorp Cloud using Robocorp Workforce Agent or Assistant, you need to provide the environment variables using the Robocorp Cloud user interface, or by defining the environment variables in the target system where Robocorp Workforce Agent or Assistant is installed.
Running the full robot in a clean environment
Robocorp Lab provides a way to run your robot in a clean Conda environment by using the
Run Robot functionality. This simulates the way Robocorp Workforce Agent and Assistant creates a new Conda environment before running the robot. This type of run is useful for checking that there are no local dependencies that might be missing from the
The robot run will take longer to complete than the Notebook run since a fresh Conda environment is created before running the robot. It is typically best to use the robot run mode as the last quality assurance step before uploading the robot to Robocorp Cloud.
Running a part of the robot in Notebook mode
It is possible to run individual Robot Framework keywords in Robocorp Lab by running individual Notebook cells. The Notebook is parsed from top to bottom. To parse the full Notebook, select
Run All Cells from the main menu. This will run the full robot. After the run, the parsed keywords stay in the memory and can be executed individually by using the widget under each cell.
For example, when executing the following cell, the browser is opened and remains open:
Running the selected cell in Robocorp Lab
Robocorp Lab provides multiple ways to run your robot. The execution happens in a virtual environment created using Conda. The Notebook run is the fastest way to run your robot. The robot run should be used as the final step before uploading your robot to Robocorp Cloud, to ensure it works in a clean Conda environment when run in the runtime environment.