-
Notifications
You must be signed in to change notification settings - Fork 343
CML with GitLab
CML is designed to work with both GitHub Actions and GitLab CI. Here, we'll discuss setting up CML with GitLab.
CML allows you to generate visual reports about your workflow on Merge Requests:
The key file in any GitLab CI project is .gitlab-ci.yml
. For example, to generate the report pictured above, your .gitlab-ci.yml
file should look like this:
# .gitlab-ci.yml
stages:
- cml_run
cml:
stage: cml_run
image: dvcorg/cml-py3:latest
script:
- pip3 install -r requirements.txt
- python train.py
- cat metrics.txt >> report.md
- cml-publish confusion_matrix.png --md >> report.md
- cml-send-comment report.md
CML in GitLab works exactly as in GitHub except for a few conventions:
To use CML, you must create a variable called repo_token
whose value is a Personal Access Token:
-
Create a Personal Access Token by navigating to User Settings → Access Tokens.
-
In the "Name" field, type "repo_token" and check boxes to select "api", "read_repository" and "write_repository". Then click "Create personal access token".
-
Copy the generated Personal Access Token.
-
In your GitLab project, navigate to Settings → CI/CD → Variables.
-
Click "Add Variable". In the Key field, type "repo_token". In the Value field, paste your Personal Access Token. Check the "Mask variable" box, uncheck "Protect variable", and then save the variable by clicking "Add variable" at the bottom of the dialog box.
Tada, 🎩✨ repo_token
is saved! You can follow this procedure (specifically, steps 4 & 5) for adding other secrets, like access credentials for cloud storage,
Please see the example on our README, noting one difference: repository credentials are still required, but are entered as Variables instead of Secrets.
Follow GitLab's instructions to set up a runner manually or with a Kubernetes cluster.