Skip to content

Commit

Permalink
Create Bitbucket getting started guide (#257)
Browse files Browse the repository at this point in the history
* Create Bitbucket getting started guide

* Apply suggestions from code review

Co-authored-by: Daniel Barnes <[email protected]>

* Rename confusion_matrix.png to plot.png

* Apply suggestions from code review

Co-authored-by: Daniel Barnes <[email protected]>

* Add token instructions

* Add more workarounds to the instructions

Co-authored-by: Daniel Barnes <[email protected]>
  • Loading branch information
0x2b3bfa0 and dacbd authored Jun 17, 2022
1 parent 78e21b0 commit 1d0c8aa
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions content/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
{
"label": "GitLab",
"slug": "gitlab"
},
{
"label": "Bitbucket",
"slug": "bitbucket"
}
]
},
Expand Down
78 changes: 78 additions & 0 deletions content/docs/start/bitbucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Get Started with CML on Bitbucket

Here, we'll walk through a tutorial to start using CML. For simplicity, we'll
show the demo in Bitbucket Pipelines, but instructions are pretty similar for
all the supported CI systems.

1. Fork our
[example project repository](https://bitbucket.org/iterative-ai/example-cml).

![](/img/bitbucket_fork_cml_project.png)

The following steps can all be done in the Bitbucket browser interface.
However, to follow along the commands, we recommend cloning your fork to your
local workstation:

```bash
git clone https://bitbucket.org/<your-username>/example-cml
```

2. ⚠️ Follow
[these instructions](https://cml.dev/doc/self-hosted-runners?tab=Bitbucket#personal-access-token)
to configure a Bitbucket token for CML.
3. ⚠️ Follow
[these instructions](https://cml.dev/doc/ref/send-comment#bitbucket) to
enable the Pull Request Commit Links application.

4. To create a CML workflow, copy the following into a new file on your main
branch, `bitbucket-pipelines.yml`:

```yaml
image: iterativeai/cml:0-dvc2-base1
pipelines:
default:
- step:
name: Train model
script:
- pip install -r requirements.txt
- python train.py
- cat metrics.txt > report.md
- cml-publish plot.png --md >> report.md
- cml-send-comment report.md
```

5. In your text editor of choice, edit line 15 of `train.py` to `depth = 12`.

6. Commit and push the changes:

```bash
git checkout -b experiment
git add . && git commit -m "modify forest depth"
git push origin experiment
```

7. In Bitbucket, create a Pull Request to compare the `experiment` branch to
`master`.

![](/img/bitbucket_make_pr.png)

Shortly, you should see a comment from your user appear in the Pull Request
with your CML report. This is a result of the `cml send-comment` command in
your workflow.

![](/img/bitbucket_cml_first_report.png)

This is the gist of the CML workflow: when you push changes to your Bitbucket
repository, the workflow in your `bitbucket-pipelines.yml` file gets run and a
report generated.

CML commands let you display relevant results from the workflow, like model
performance metrics and vizualizations, in Bitbucket checks and comments. What
kind of workflow you want to run, and want to put in your CML report, is up to
you.

## Final Solution

An example of what your repository should look like now can be found at
[`iterative-ai/cml-base-case`](https://bitbucket.org/iterative-ai/cml-base-case).
Binary file added static/img/bitbucket_cml_first_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/bitbucket_fork_cml_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/bitbucket_make_pr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d0c8aa

Please sign in to comment.