Robocorp CLI workflow

This article demonstrates an example workflow from the creation of a new robot using Robocorp CLI to successful execution in the target environment from the cloud using Robocorp Cloud and Robocorp App.

Let's get started!

Prerequisites

Set up your development environment.

You need a Robocorp Cloud account. Some experience with using the terminal or the Command Prompt is useful.

Initialize the project structure using Robocorp CLI

How should I organize my code? Where should I place my files? Is there a naming convention I should follow?

Those are some of the questions that Robocorp CLI can help you with.

Navigate to your projects directory in the terminal or the command prompt. Initialize the software robot directory:

robo init my-robot

This initializes the recommended directory and file structure for the robot. An example robot is also provided. This robot can be used to verify that execution works before creating your own robot. You'll find helpful .md files that explain the purpose of each directory.

Navigate to the robot directory:

cd my-robot

Adding Python packages

If your robot requires additional Python packages, you can use pip install --upgrade somepackagehere to install them into your current virtual environment.

To be able to execute the robot in any other environment, you will want to provide the dependencies in the conda.yaml file in the config directory as well.

When installing new packages with pip, make sure to keep the conda.yaml in sync, too. Otherwise, when using Robocorp App, the execution in other environments will fail due to missing dependencies.

For example, if your robot requires the numpy package:

pip install --upgrade numpy

Update the conda.yaml:

robo libs --add --pip numpy

Note that using the conda.yaml is not mandatory. When the conda.yaml file exists, Robocorp App will set up a conda environment in the target system based on the conda.yaml file. When the conda.yaml file does not exist, Robocorp App will not set up the conda environment. In this case, it is up to you to provide the environment for your robot. This gives you full control, should you want to control the execution environment yourself.

The default robot that robo init creates contains the rpaframework package as a dependency. If you do not need it, you can delete it from the config/conda.yml file.

Create an executable package using Robocorp CLI

A package is required when you want to execute your robot, upload your robot, and to download your robot from Robocorp Cloud. The package will contain all of your robot code and other required resources. The package will also contain an entry point file. This entry point file will be referred from Robocorp Cloud when executing your robot.

Create the package:

robo wrap

The robo wrap command protects you from accidentally overriding your existing package. If you want to rerun the wrap when a package already exists, use:

robo wrap --force

Note that wrapping is always needed to update the code in the current package. If you change your robot code and try to execute it without rewrapping, you will be executing the old code in the existing package, instead of the new code you just created or modified.

Execute the robot locally using Robocorp CLI

After creating a package, you can proceed to execute your robot.

The robo run command expects an entry point file. The entry point file is referenced directly without a relative path.

Windows:

robo run entrypoint.cmd

macOS / Linux:

robo run entrypoint.sh

If everything worked, your robot should have been executed successfully. The execution produces output in the terminal or the command prompt. It will also generate log files. These can be opened in a browser to view the details of the execution.

When the robot execution works locally on your machine, you can try and execute the robot from Robocorp Cloud.

Setup Robocorp Cloud

To start the robot execution in the target environment from Robocorp Cloud, you want to do some preparations in Robocorp Cloud. Log in to Robocorp Cloud.

  1. Select or create the organization and the workspace where you want to run your robot.

  2. Download, install, start, and link Robocorp App with Robocorp Cloud (in this case, Robocorp App resides in your development environment). Robocorp App will take care of setting up a virtual execution environment, downloading, extracting, and executing the robot.

  3. Create access credentials for the Robocorp Cloud CLI in Robocorp Cloud. Robocorp CLI needs these credentials to communicate with Robocorp Cloud. Copy the credentials to the clipboard.

Robocorp Cloud access credentials in user preferences

Robocorp Cloud access credentials list

Robocorp Cloud access credentials view

Provide the access credentials to Robocorp CLI

robo credentials PASTEYOURCREDENTIALSHERE

Upload the robot to Robocorp Cloud

You can get the command for uploading the code for your robot by navigating to the robot page in Robocorp Cloud: Getting upload command from Robocorp Cloud

Upload the robot to Robocorp Cloud using Robocorp CLI by providing the workspace ID (--workspace), and the activity ID (--activity), for example:

robo upload --workspace 111 --activity 111

Note that you can indeed upload the robot from Robocorp Cloud UI, too. Robocorp CLI provides a way to complete the upload without the need to use the Robocorp Cloud UI. This can be useful when doing iterative development, since you do not need to leave the command-line to upload packages, etc. Other use cases include automated Continuous Integration builds, where you want to periodically upload the current package without manual intervention.

Create a process and add your robot step to it

Create a new process in your workspace, and add your test robot to it: Add process and add a robot step to it

Attach your runtime environment: Attach the runtime environment

Run the process

Execute the robot from Robocorp Cloud. Robocorp App should set up a virtual execution environment, download, extract, and execute the robot.

Running the process from Robocorp Cloud

Iterate

You can iterate the development of your robot either locally or through the cloud.

Iterating locally consists of coding, wrapping, and executing.

Cloud iteration consists of coding, wrapping, uploading, and executing.