Skip to content

Commit

Permalink
feat(example-get-started): add GitLab CI to publish reports (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein authored May 6, 2024
1 parent 3eb148c commit 1ab0473
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
50 changes: 50 additions & 0 deletions example-get-started/code/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
report:
image: dvcorg/cml:0-dvc3-base1
before_script:
- cml ci
- npm install -g json5
script: |
if [ $CI_COMMIT_BRANCH = main ]; then
PREVIOUS_REF=HEAD~1
else
PREVIOUS_REF=main
git fetch --depth=1 origin main:main
fi
dvc pull eval
dvc plots diff $PREVIOUS_REF workspace \
--show-vega --targets ROC | json5 > vega.json
vl2svg vega.json roc.svg
dvc plots diff $PREVIOUS_REF workspace \
--show-vega --targets Precision-Recall | json5 > vega.json
vl2svg vega.json prc.svg
dvc plots diff $PREVIOUS_REF workspace \
--show-vega --targets Confusion-Matrix | json5 > vega.json
vl2svg vega.json confusion.svg
cp eval/plots/images/importance.png importance_workspace.png
git checkout $PREVIOUS_REF -- dvc.lock
cp eval/plots/images/importance.png importance_previous.png
dvc_report=$(dvc exp diff $PREVIOUS_REF --md)
cat <<EOF > report.md
# CML Report
## Plots
![ROC](./roc.svg)
![Precision-Recall](./prc.svg)
![Confusion Matrix](./confusion.svg)
#### Feature Importance: ${PREVIOUS_REF}
![Feature Importance: ${PREVIOUS_REF}](./importance_previous.png)
#### Feature Importance: workspace
![Feature Importance: workspace](./importance_workspace.png)
## Metrics and Params
### ${PREVIOUS_REF} → workspace
${dvc_report}
EOF
cml comment create --publish --pr=false report.md
4 changes: 2 additions & 2 deletions example-get-started/code/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![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 Get Started

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

## Installation

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

```console
$ git clone https://github.com/iterative/example-get-started
Expand Down
3 changes: 2 additions & 1 deletion example-get-started/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rm -rf $TEST_DIR
mkdir $TEST_DIR

pushd $PACKAGE_DIR
zip -r $PACKAGE params.yaml src/* .github/* .devcontainer/*
zip -r $PACKAGE params.yaml src/* .github/*
popd

# Requires AWS CLI and write access to `s3://dvc-public/code/get-started/`.
Expand All @@ -32,6 +32,7 @@ if [ $PROD == 'prod' ]; then
rm -f $TEST_PACKAGE
cp -f $PACKAGE_DIR/README.md $TEST_DIR
cp -f $PACKAGE_DIR/.devcontainer.json $TEST_DIR
cp -f $PACKAGE_DIR/.gitlab-ci.yml $TEST_DIR
cp -f $PACKAGE_DIR/.gitattributes $TEST_DIR
diff -r $PACKAGE_DIR $TEST_DIR # Expected output: nothing
rm -fR $TEST_DIR
Expand Down
1 change: 1 addition & 0 deletions example-get-started/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ if [ $OPT_INIT_GIT == 'true' ]; then
git checkout -b main
cp $HERE/code/README.md .
cp $HERE/code/.devcontainer.json .
cp $HERE/code/.gitlab-ci.yml .
cp $HERE/code/.gitattributes .
git add .
else
Expand Down

0 comments on commit 1ab0473

Please sign in to comment.