iterative / cml.dev

🔗 CML website and documentation
https://cml.dev
Apache License 2.0
13 stars 23 forks source link

Update `cml-with-dvc` example. #172

Open daavoo opened 2 years ago

daavoo commented 2 years ago

Note that this hasn't been released yet but it's merged on master:


For the vega example in https://cml.dev/doc/cml-with-dvc using vl2png, how can this be handled with --json?

Some json manipulation is needed for that. In this particular example:

dvc plots diff \
            --target classes.csv \
            --template confusion \
            -x actual \
            -y predicted \
            --json master | jq '."classes.csv" | .[0]' >> vega.json

I think send-comment with vega plot is a widely used example

Originally posted by @daavoo in https://github.com/iterative/dvc/issues/7093#issuecomment-998095565

casperdcl commented 2 years ago

What's the advantage of --json | jq <filter> > vega.json over --show-vega > vega.json when we still need to use vl2png anyway?

If we could do something like --json | python -c 'import matplotlib.pyplot as plt, sys; plt.plot(eval(sys.stdin.read())["classes.csv"][0])' instead that would be nice

daavoo commented 2 years ago

What's the advantage of --json | jq <filter> > vega.json over --show-vega > vega.json when we still need to use vl2png anyway?

We can use --show-vega for this example, as long as the flag is not removed 😅.

One difference is that --show-vega only works for a single plot whereas --json can return the list of all plots for a rev. So, jq could be used to do a for loop calling vl2png and cml send-comment. It would be handy for dvclive plots.

Another thing is that --show-vega doesn't return image plots. --json could be used to combine image plots and cml publish.

If we could do something like --json | python -c 'import matplotlib.pyplot as plt, sys; plt.plot(eval(sys.stdin.read())["classes.csv"][0])' instead that would be nice

What would be the advantage over jq?

casperdcl commented 2 years ago

What would be the advantage over jq?

You mean "what would be the advantage of --json | python -c '...' over --json | jq <filter> > vega.json && vl2png ...?"

No reliance on vl2png nor jq.