Search code examples
mlopsdvccml

Not able to update experiment metrics from iterative.ai studio


I have DVC and gitlab-ci integrated using CML and with studio as well. But whenever I run an experiment from studio dashboard, the new experiment appears on the dashboard but metrics don't get updated in git and thus in studio dashboard as well. But yes the updated metrics are shown in the merge comment. Is there a way update metrics in git repo and studio as well. My gitlab-ci.yml is as follows.

train-and-report:
  image: iterativeai/cml:0-dvc2-base1 # Python, DVC, & CML pre-installed
  script:
    - pip install -r requirements.txt # Install dependencies
    - dvc repro # Reproduce pipeline

    # Create CML report
    - echo "## Metrics workflow vs. main" >> report.md
    - git fetch --depth=1 origin main:main
    - dvc metrics diff --show-md main >> report.md

    - echo "## Plots" >> report.md
    - echo "### Training loss function diff" >> report.md
    - dvc plots diff --target dvclive/plots/metrics/number.tsv --show-vega main > vega.json
    - vl2png vega.json > plot.png
    - echo '![](./plot.png "Training Loss")' >> report.md

    - cml comment create report.md

Is there something I am missing to update the metrics within the git itself.


Solution

  • You need to save (commit and push) your results, otherwise neither you, GitLab, nor Iterative Studio will be able to retrieve any results.

    ...
    # add a comment to GitLab
    - cml comment create report.md
    
    # upload code/metadata
    - cml pr create . # this will git commit, push, and open a merge request
    # upload data/artefacts
    - dvc push
    

    Note for dvc push to work, you will need to setup storage credentials if you haven't done so already.