dvc icon indicating copy to clipboard operation
dvc copied to clipboard

`stage`: list/show/get stage details

Open dberenbaum opened this issue 2 years ago • 3 comments

CLI command and API method to get all stage info (cmd, params, deps, outs, etc.).

  • CLI command is useful for seeing the resolved info for stages using interpolation
  • API method is useful for getting paths so you don't have to manually align them between code and dvc.yaml

Loosely related to https://github.com/iterative/vscode-dvc/issues/5048:

With a complicated DVC pipeline, with dynamic parametrized dependencies it's not easy to get an exact command that is needed to run a specific stage under debugger outside of DVC.

Example:

$ cat dvc.yaml
stages:
  train:
    cmd: python src/train.py ${data_path}/features ${model_path} ${train}
    deps:
    - ${data_path}/features
    - src/train.py
    params:
    - train
    outs:
    - ${model_path}
    - dvclive:
        cache: false

$ dvc stage show train --json
{
  "cmd": "python src/train.py data/features model.pkl min_split=0.2 n_est=50 seed=101",
  "deps": [
    "data/features",
    "model.pkl"
  ],
  "params": {
    "train": {
      "min_split": 0.2,
      "n_est": 50,
      "seed": 101,
    }
  },
  "outs": {
    "model.pkl": {},
    "dvclive": {"cache": false}
  }
}

API usage:

from dvc.api import stage_show

outs = stage_show("train").outs
with open(outs[0].path, "w") as f:
    f.write(model)

dberenbaum avatar Dec 16 '23 12:12 dberenbaum

@iterative/vs-code How can we show the resolved stages in the extension so it's easy to edit and debug dvc.yaml?

dberenbaum avatar Dec 23 '23 12:12 dberenbaum

Maybe we could show stages in a tree in a sidebar view.

image

julieg18 avatar Jan 02 '24 16:01 julieg18

@julieg18 I was initially thinking along the lines of the ideas in https://github.com/iterative/vscode-dvc/issues/1192, but maybe a dedicated sidebar view like you suggest is better 🤔.

dberenbaum avatar Jan 02 '24 20:01 dberenbaum