Repository navigation
5 Robot Deployment
There are several ways to execute a robot. This section describes the execution methods that have been tested during development.
Regardless of the execution method, the robot must be configured to communicate with a DESTINY repository, either a locally running instance or the production repository. The repository connection is configured via the robot's .env file. Instructions for configuring a robot to connect to a local DESTINY repository are provided in this Section, while the configuration for connecting to the production repository is described in here.
In addition, enhancement batches must be available for the robot to process. When working with a local DESTINY repository, enhancement requests can be created as described here.
The simplest way to execute a robot is directly from a local Python virtual environment.
For example, to start the Relevance Robot:
uv run python -m relevance_robotIf you implemented your robot with the polling runner you need to shut it down with Ctrl+C. The batch runner will exit after all available batches have been processed.
A robot can also be executed automatically via a GitLab Pipeline Schedule while still running on your local machine. This is especially suitable for robots using the BatchRunner.
First, install the GitLabRunner on your local machine. Give the runner a suitable tag, e.g. local-runner, choose the appropriate operating system, and follow the instructions for registering the runner.
When prompted:
-
Run the registration command as
**sudo**. This registers the runner in system mode. The runner service subsequently executes jobs as thegitlab-runneruser. -
When prompted
Enter an executor:, select:shell
The Shell executor runs the CI jobs directly on the local machine. This allows the workflow to access resources available on that machine, such as locally stored machine-learning models and, for local testing, a locally running DESTINY repository.
After registration, enable and start the GitLab Runner service:
sudo systemctl enable gitlab-runner
sudo systemctl start gitlab-runnerCheck that the service is running:
sudo systemctl status gitlab-runnerThe runner registration can be verified with:
sudo gitlab-runner verifyA successful verification should report:
Running in system-mode. Verifying runner... is validThe runner should also appear as online in the GitLab project's runner settings.
Note: Because the runner executes jobs as the gitlab-runner user, software and files required by the CI pipeline must be accessible to this user.
The GitLab Runner is configured via a .gitlab-ci.yml file located in the root directory of the robot project. This file specifies how the robot should be executed whenever a GitLab pipeline is triggered.
A Shell runner creates a fresh checkout of the repository in a dedicated build directory before executing the pipeline. Consequently, the pipeline cannot rely on the Python virtual environment or locally generated files (e.g. trained machine learning models) contained in the original working directory. Instead, these resources have to be recreated or copied into the build directory as part of the pipeline.
The different parts of the example are explained below.
stages:
- run
run-robot-workflow:
stage: run
tags:
- local-runner
resource_group: robot-workflowThis means that the pipeline has one stage called run, and the job run-robot-workflow belongs to that stage. The tags field specifies which GitLab Runner should execute the job. The resource_group ensures that only one instance of the Relevance Robot is executed at any given time. If a new scheduled pipeline is triggered while a previous execution is still running, the new job is queued until the previous one has completed.
Before the robot is executed, the required Python environment is created:
before_script:
- export PATH="$HOME/.local/bin:$PATH"
- uv sync
- uv run python --version
- cd query_robot
- uv sync
- cd ../cluster_relevance_robot
- uv sync
- cd ../cluster_label_robot
- uv sync
- cd ..The first uv sync sets up the environment for the outer project, which contains shared functionality such as base_robot. The subsequent commands create the environments for the individual robots.
The uv.lock files are committed to the repository and ensure that the same dependency versions are installed when the pipeline runs on another machine.
The robot credentials are not stored in the repository. Instead, they are configured as GitLab CI/CD variables and used to create the .env files required by the individual robots.
For example:
- |
cat > query_robot/.env << EOF
ROBOT_ID=${QUERY_ROBOT_ID}
ROBOT_SECRET=${QUERY_ROBOT_SECRET}
DESTINY_REPOSITORY_URL=${DESTINY_REPOSITORY_URL}
ENV=local
EOFThe corresponding .env files are created for the cluster-based robots.
The trained machine-learning models are not stored in the Git repository. They are stored separately on the machine running the GitLab Runner.
The location of the model directory is specified using MODEL_SOURCE:
variables:
MODEL_SOURCE: "/path/to/destiny-robot-models"The pipeline copies the required models into the GitLab checkout:
- mkdir -p cluster_relevance_robot/models
- rsync -a --exclude='.cache/' "${MODEL_SOURCE}/cluster_relevance_robot/models/" cluster_relevance_robot/models/
- mkdir -p cluster_label_robot/models
- rsync -a --exclude='.cache/' "${MODEL_SOURCE}/cluster_label_robot/models/" cluster_label_robot/models/MODEL_SOURCE is therefore machine-specific and must be adjusted when the pipeline is set up on another machine.
The gitlab-runner user must have read access to the model directory. For example, on a Linux machine, read and directory-traversal permissions can be granted using ACLs:
setfacl -R -m u:gitlab-runner:rX /path/to/destiny-robot-modelsThe permission should be granted only to the directory containing the model artefacts rather than to the user's entire home directory.
rsync is used instead of a simple cp -r because it allows directories to be copied recursively while selectively excluding files or directories that are not required. In particular, the Hugging Face .cache directories do not need to be copied when the locally downloaded model files themselves are available. This also avoids copying unnecessary cache data into the temporary GitLab checkout.
The script section specifies the command that starts the robot. The rules section restricts execution of the job to pipelines triggered by a GitLab Pipeline Schedule.
Once the GitLab Runner and the pipeline configuration have been set up, the robot can be executed automatically using a GitLab Pipeline Schedule.
In GitLab, navigate to:
Build → Pipelines → Pipeline Schedules
Choose a description, a time zone and a suitable cron interval (e.g. */10 * * * * to execute the robot every 10 minutes).
Nest, add the configuration variables required by the robot under Variables. These correspond to the values normally stored in the robot's .env file (e.g. ROBOT_ID, ROBOT_SECRET, and DESTINY_REPOSITORY_URL).
Note: Variable values are stored literally by GitLab. Do not enclose values in quotation marks. For example, UUIDs such as
ROBOT_IDshould be entered as
cb73f9a3-af2a-4bfa-9502-f61d5fe18b11
Finally, click Create pipeline schedule.
The scheduled pipeline is now configured and will execute according to the specified cron interval. During development, the schedule can also be started manually by clicking the Run (▶) button next to the pipeline schedule.