Skip to content

Commit 1ab0473

Browse files
authored
feat(example-get-started): add GitLab CI to publish reports (#283)
1 parent 3eb148c commit 1ab0473

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
report:
2+
image: dvcorg/cml:0-dvc3-base1
3+
before_script:
4+
- cml ci
5+
- npm install -g json5
6+
script: |
7+
if [ $CI_COMMIT_BRANCH = main ]; then
8+
PREVIOUS_REF=HEAD~1
9+
else
10+
PREVIOUS_REF=main
11+
git fetch --depth=1 origin main:main
12+
fi
13+
14+
dvc pull eval
15+
dvc plots diff $PREVIOUS_REF workspace \
16+
--show-vega --targets ROC | json5 > vega.json
17+
vl2svg vega.json roc.svg
18+
19+
dvc plots diff $PREVIOUS_REF workspace \
20+
--show-vega --targets Precision-Recall | json5 > vega.json
21+
vl2svg vega.json prc.svg
22+
23+
dvc plots diff $PREVIOUS_REF workspace \
24+
--show-vega --targets Confusion-Matrix | json5 > vega.json
25+
vl2svg vega.json confusion.svg
26+
27+
cp eval/plots/images/importance.png importance_workspace.png
28+
29+
git checkout $PREVIOUS_REF -- dvc.lock
30+
cp eval/plots/images/importance.png importance_previous.png
31+
32+
dvc_report=$(dvc exp diff $PREVIOUS_REF --md)
33+
34+
cat <<EOF > report.md
35+
# CML Report
36+
## Plots
37+
![ROC](./roc.svg)
38+
![Precision-Recall](./prc.svg)
39+
![Confusion Matrix](./confusion.svg)
40+
#### Feature Importance: ${PREVIOUS_REF}
41+
![Feature Importance: ${PREVIOUS_REF}](./importance_previous.png)
42+
#### Feature Importance: workspace
43+
![Feature Importance: workspace](./importance_workspace.png)
44+
45+
## Metrics and Params
46+
### ${PREVIOUS_REF} → workspace
47+
${dvc_report}
48+
EOF
49+
50+
cml comment create --publish --pr=false report.md

example-get-started/code/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![DVC](https://img.shields.io/badge/-Open_in_Studio-grey.svg?style=flat-square&logo=dvc)](https://studio.iterative.ai/team/Iterative/views/example-get-started-zde16i6c4g) [![DVC-metrics](https://img.shields.io/badge/dynamic/json?style=flat-square&colorA=grey&colorB=F46737&label=Average%20Precision&url=https://github.com/iterative/example-get-started/raw/main/eval/metrics.json&query=avg_prec.test)](https://github.com/iterative/example-get-started/raw/main/eval/metrics.json)
1+
[![DVC](https://img.shields.io/badge/-Open_in_Studio-grey.svg?style=flat-square&logo=dvc)](https://studio.iterative.ai/team/Iterative/views/example-get-started-zde16i6c4g)
22

33
# DVC Get Started
44

@@ -18,7 +18,7 @@ classifier which can predict a post that is about the R language by tagging it
1818

1919
## Installation
2020

21-
Python 3.7+ is required to run code from this repo.
21+
Python 3.9+ is required to run code from this repo.
2222

2323
```console
2424
$ git clone https://github.com/iterative/example-get-started

example-get-started/deploy.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rm -rf $TEST_DIR
1313
mkdir $TEST_DIR
1414

1515
pushd $PACKAGE_DIR
16-
zip -r $PACKAGE params.yaml src/* .github/* .devcontainer/*
16+
zip -r $PACKAGE params.yaml src/* .github/*
1717
popd
1818

1919
# Requires AWS CLI and write access to `s3://dvc-public/code/get-started/`.
@@ -32,6 +32,7 @@ if [ $PROD == 'prod' ]; then
3232
rm -f $TEST_PACKAGE
3333
cp -f $PACKAGE_DIR/README.md $TEST_DIR
3434
cp -f $PACKAGE_DIR/.devcontainer.json $TEST_DIR
35+
cp -f $PACKAGE_DIR/.gitlab-ci.yml $TEST_DIR
3536
cp -f $PACKAGE_DIR/.gitattributes $TEST_DIR
3637
diff -r $PACKAGE_DIR $TEST_DIR # Expected output: nothing
3738
rm -fR $TEST_DIR

example-get-started/generate.sh

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ if [ $OPT_INIT_GIT == 'true' ]; then
146146
git checkout -b main
147147
cp $HERE/code/README.md .
148148
cp $HERE/code/.devcontainer.json .
149+
cp $HERE/code/.gitlab-ci.yml .
149150
cp $HERE/code/.gitattributes .
150151
git add .
151152
else

0 commit comments

Comments
 (0)