From 4b246b80f20b4a0ae63c8353c5b849f4a90d61c7 Mon Sep 17 00:00:00 2001 From: Ivan Shcheklein Date: Sat, 4 May 2024 11:23:03 -0700 Subject: [PATCH] feat(example-get-started): add GitLab CI to publish reports --- example-get-started/code/.gitlab-ci.yml | 50 +++++++++++++++++++++++++ example-get-started/code/README.md | 4 +- example-get-started/deploy.sh | 3 +- example-get-started/generate.sh | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 example-get-started/code/.gitlab-ci.yml diff --git a/example-get-started/code/.gitlab-ci.yml b/example-get-started/code/.gitlab-ci.yml new file mode 100644 index 0000000..05bcb0d --- /dev/null +++ b/example-get-started/code/.gitlab-ci.yml @@ -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 < 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 diff --git a/example-get-started/code/README.md b/example-get-started/code/README.md index 8e7ae0b..a59a91d 100644 --- a/example-get-started/code/README.md +++ b/example-get-started/code/README.md @@ -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 @@ -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 diff --git a/example-get-started/deploy.sh b/example-get-started/deploy.sh index f0e8d4b..77c39e7 100755 --- a/example-get-started/deploy.sh +++ b/example-get-started/deploy.sh @@ -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/`. @@ -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 diff --git a/example-get-started/generate.sh b/example-get-started/generate.sh index 339c57a..c022458 100755 --- a/example-get-started/generate.sh +++ b/example-get-started/generate.sh @@ -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