Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 5c8c497

Browse files
authored
update & sync getting started guides (#275)
1 parent ea1a50f commit 5c8c497

File tree

3 files changed

+70
-71
lines changed

3 files changed

+70
-71
lines changed

content/docs/self-hosted-runners.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,18 @@ Use either:
325325
For instance, to use a personal access token:
326326

327327
1. Navigate to **User Settings** → **Access Tokens**
328+
328329
- in the "Name" field, type `REPO_TOKEN`
329330
- select `api`, `read_repository` and `write_repository`
330331
- click "Create personal access token" and copy it
331-
2. In your GitLab project, navigate to **Settings** → **CI/CD**
332+
333+
![](/img/personal_access_token.png)
334+
335+
1. In your GitLab project, navigate to **Settings** → **CI/CD**
332336
→ **Variables** → **Add Variable**
337+
338+
![](/img/ci_cd_navigation.png)
339+
333340
- in the "Key" field, type `REPO_TOKEN`
334341
- in the "Value" field, paste your Personal Access Token
335342
- select "Mask variable"

content/docs/start/github.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ supported CI systems.
99

1010
![](/img/fork_cml_project.png)
1111

12-
The following steps can all be done in the GitHub browser interface. However,
13-
to follow along the commands, we recommend cloning your fork to your local
14-
workstation:
12+
<admon type="tip">
1513

16-
```cli
17-
$ git clone https://github.com/<your-username>/example_cml
18-
```
14+
The following steps can all be done in the GitHub browser interface. However, to
15+
follow along the commands, we recommend cloning your fork to your local
16+
workstation:
17+
18+
```cli
19+
$ git clone https://github.com/<your-username>/example_cml
20+
$ cd example_cml
21+
```
1922

20-
2. To create a CML workflow, copy the following into a new file,
23+
</admon>
24+
25+
2. To create a CML workflow, copy the following into a new file at
2126
`.github/workflows/cml.yaml`:
2227

2328
```yaml
@@ -43,7 +48,7 @@ supported CI systems.
4348
cml send-comment report.md
4449
```
4550
46-
3. In your text editor of choice, edit line 16 of `train.py` to `depth = 5`.
51+
3. In your text editor, open `train.py` and modify line 15 to `depth = 5`.
4752

4853
4. Commit and push the changes:
4954

@@ -56,6 +61,12 @@ supported CI systems.
5661
5. In GitHub, create a Pull Request to compare the `experiment` branch to
5762
`master`.
5863

64+
<admon type="warn">
65+
66+
Ensure the target is your fork (under your username).
67+
68+
</admon>
69+
5970
![](/img/make_pr.png)
6071

6172
Shortly, you should see a comment appear in the Pull Request with your CML

content/docs/start/gitlab.md

+43-62
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,88 @@
1-
# Using CML on GitLab
1+
# Get Started with CML on GitLab
22

3-
Here, we'll walk through a tutorial to start using CML on GitLab.
3+
Here, we'll walk through a tutorial to start using CML. For simplicity, we'll
4+
show the demo in GitLab CI/CD, but instructions are pretty similar for all the
5+
supported CI systems.
46

57
1. Fork our
68
[example project repository](https://gitlab.com/iterative.ai/example_cml).
7-
Click on Fork and select the namespace where you would like to keep the
8-
project.
99

1010
![](/img/gitlab_fork_cml_project.png)
1111

12-
2. ⚠️ In GitLab, to use CML, you must create a variable called a `REPO_TOKEN`
13-
whose value is a Personal Access Token. To do this:
12+
2. ⚠️ Follow
13+
[these instructions](https://cml.dev/doc/self-hosted-runners?tab=GitLab#personal-access-token)
14+
to configure a GitLab access token for CML.
1415

15-
a. Click on your Avatar in the upper right side and click on "Edit Profile."
16+
<admon type="tip">
1617

17-
b. Along the left side of the screen go to Access Tokens.
18+
The following steps can all be done in the GitLab browser interface. However, to
19+
follow along the commands, we recommend cloning your fork to your local
20+
workstation:
1821

19-
c. In the "Name" field, type `REPO_TOKEN` and check boxes to select `api`,
20-
`read_repository` and `write_repository`.
22+
```cli
23+
$ git clone https://gitlab.com/<your-username>/example_cml
24+
$ cd example_cml
25+
```
2126

22-
d. Click on the "Create personal access token" button and copy the generated
23-
access token.
27+
![](/img/gitlab_cml_clone.png)
2428

25-
![](/img/personal_access_token.png)
29+
</admon>
2630

27-
e. Head back to your fork by clicking the Projects tab next to the GitLab
28-
logo and select it.
29-
30-
f. On the left hand side Navigate to **Settings****CI/CD**
31-
**Variables**.
32-
33-
![](/img/ci_cd_navigation.png)
34-
35-
f. Scroll to Variables and expand the field. Click "Add Variable". In the Key
36-
field, type `REPO_TOKEN`. In the Value field, paste your Personal Access
37-
Token. Check the "Mask variable" box, uncheck "Protect variable", and then
38-
save the variable by clicking "Add variable" at the bottom of the dialog box.
39-
40-
> 💡 The following steps can all be done in the GitLab website. However, to
41-
> follow along the steps, we recommend cloning your fork to your local
42-
> workstation.
43-
44-
3. Go back to your forked `example_cml` project. Copy the Clone with HTTPS as
45-
shown in the image below, and then in your terminal, type the following
46-
command, replacing `<user_name>` with your own from GitLab.
47-
48-
![](/img/gitlab_cml_clone.png)
49-
50-
```cli
51-
$ git clone https://gitlab.com/<user_name>/example_cml.git
52-
```
53-
54-
4. Change directory to `example_cml`.
55-
56-
```cli
57-
$ cd example_cml
58-
```
59-
60-
5. To create a CML workflow, use your editor of choice to copy the following
61-
into a new file `.gitlab-ci.yml` and save.
31+
3. To create a CML workflow, copy the following into a new file named
32+
`.gitlab-ci.yml`:
6233

6334
```yaml
6435
train-and-report:
6536
image: iterativeai/cml:0-dvc2-base1
6637
script:
6738
- pip install -r requirements.txt
6839
- python train.py
40+
6941
- cat metrics.txt >> report.md
7042
- cml publish plot.png --md >> report.md
7143
- cml send-comment report.md
7244
```
7345
74-
6. In your text editor, open `train.py` and edit line 16 to `depth = 5`.
46+
4. In your text editor, open `train.py` and modify line 15 to `depth = 5`.
7547

76-
7. Commit and push the changes using:
48+
5. Commit and push the changes:
7749

7850
```cli
7951
$ git checkout -b experiment
8052
$ git add . && git commit -m "modify forest depth"
8153
$ git push origin experiment
8254
```
8355

84-
8. Go back to GitLab in a Browser window and create a merge request.
56+
6. In GitLab, create a Merge Request to compare the `experiment` branch to
57+
`master`.
8558

8659
![](/img/create_merge_request.png)
8760

88-
9. If you arrive at a New Merge Request screen that says it's merging into
89-
anything _other_ than your local repository, click on `Change branches` seen
90-
here.
61+
The "New Merge Request" page will let you **Change branches**:
9162

9263
![](/img/new_merge_request.png)
9364

94-
10. ⚠️ Change target branch to your local branch with your username.
65+
<admon type="warn">
66+
67+
Ensure the target is your fork (under your username):
68+
69+
![](/img/change_user_name.png)
70+
71+
</admon>
72+
73+
Continue and submit the Merge Request. Shortly, you should see a comment
74+
appear in the Merge Request with your CML report. This is a result of the
75+
`cml send-comment` command in your workflow.
9576

96-
![](/img/change_user_name.png)
77+
![](/img/cml_start_gitlab_end.png)
9778

98-
11. Click on the "Compare branches and continue" button. Enter any additional
99-
comments you would like to put in the description and click the "Submit
100-
merge request" button. Shortly, you should see a comment from GitLab CI
101-
appear in the Pull Request with your CML report. This is a result of the
102-
`cml send-comment` command in your workflow.
79+
This is the gist of the CML workflow: when you push changes to your GitLab
80+
repository, the workflow in your `.gitlab-ci.yml` file gets run and a report
81+
generated.
10382

104-
![](/img/cml_start_gitlab_end.png)
83+
CML commands let you display relevant results from the workflow, like model
84+
performance metrics and vizualizations, in GitLab comments. What kind of
85+
workflow you want to run, and want to put in your CML report, is up to you.
10586

10687
## Final Solution
10788

0 commit comments

Comments
 (0)