Repository: iterative/dvc

Issue:
exp init: Revisit `type="dl"`
Once https://github.com/iterative/dvclive/issues/225 is solved, the `live` section will be deprecated in favor of using `metrics` and `plots`.

How should `exp init` behave when `type="dl"`?


Discussion:
Would it make sense for `type="dl"` to generate:

```yaml
stages:
  train:
    cmd: python train.py
    deps:
      - train.py
    metrics:
      - dvclive.json:
          cache: false
    plots:
      - dvclive/scalars:
          cache: false
```

Where `dvclive` would be replaced by the value passed to `--live` (if any) ?
cc @dberenbaum @skshetry 
@daavoo Would you be up to contribute this change?
> @daavoo Would you be up to contribute this change?

If you all agree on proposed workaround, yes

Resolving patch:
diff --git a/dvc/repo/experiments/init.py b/dvc/repo/experiments/init.py
--- a/dvc/repo/experiments/init.py
+++ b/dvc/repo/experiments/init.py
@@ -239,18 +239,20 @@ def init(
         except MissingParamsFile:
             pass
 
-    checkpoint_out = bool(context.get("live"))
     models = context.get("models")
+    live_path = context.pop("live", None)
+    live_metrics = f"{live_path}.json" if live_path else None
+    live_plots = os.path.join(live_path, "scalars") if live_path else None
+
     stage = repo.stage.create(
         name=name,
         cmd=context["cmd"],
         deps=compact([context.get("code"), context.get("data")]),
         params=[{params: None}] if params else None,
-        metrics_no_cache=compact([context.get("metrics")]),
-        plots_no_cache=compact([context.get("plots")]),
-        live=context.get("live"),
+        metrics_no_cache=compact([context.get("metrics"), live_metrics]),
+        plots_no_cache=compact([context.get("plots"), live_plots]),
         force=force,
-        **{"checkpoints" if checkpoint_out else "outs": compact([models])},
+        **{"checkpoints" if with_live else "outs": compact([models])},
     )
 
     with _disable_logging(), repo.scm_context(autostage=True, quiet=True):


Test patch:
diff --git a/tests/func/experiments/test_init.py b/tests/func/experiments/test_init.py
--- a/tests/func/experiments/test_init.py
+++ b/tests/func/experiments/test_init.py
@@ -136,13 +136,16 @@ def test_init_interactive_when_no_path_prompts_need_to_be_asked(
             "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
-                "live": {"dvclive": {"html": True, "summary": True}},
-                "metrics": [{"metrics.json": {"cache": False}}],
-                # we specify `live` through `overrides`,
-                # so it creates checkpoint-based output.
-                "outs": [{"models": {"checkpoint": True}}],
+                "metrics": [
+                    {"dvclive.json": {"cache": False}},
+                    {"metrics.json": {"cache": False}},
+                ],
+                "outs": ["models"],
                 "params": [{"params.yaml": None}],
-                "plots": [{"plots": {"cache": False}}],
+                "plots": [
+                    {os.path.join("dvclive", "scalars"): {"cache": False}},
+                    {"plots": {"cache": False}},
+                ],
             }
         }
     }
@@ -357,9 +360,12 @@ def test_init_interactive_live(
             "train": {
                 "cmd": "python script.py",
                 "deps": ["data", "script.py"],
-                "live": {"dvclive": {"html": True, "summary": True}},
+                "metrics": [{"dvclive.json": {"cache": False}}],
                 "outs": [{"models": {"checkpoint": True}}],
                 "params": [{"params.yaml": None}],
+                "plots": [
+                    {os.path.join("dvclive", "scalars"): {"cache": False}}
+                ],
             }
         }
     }
@@ -404,11 +410,16 @@ def test_init_with_type_live_and_models_plots_provided(
             "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
-                "live": {"dvclive": {"html": True, "summary": True}},
-                "metrics": [{"m": {"cache": False}}],
+                "metrics": [
+                    {"dvclive.json": {"cache": False}},
+                    {"m": {"cache": False}},
+                ],
                 "outs": [{"models": {"checkpoint": True}}],
                 "params": [{"params.yaml": None}],
-                "plots": [{"p": {"cache": False}}],
+                "plots": [
+                    {os.path.join("dvclive", "scalars"): {"cache": False}},
+                    {"p": {"cache": False}},
+                ],
             }
         }
     }
@@ -439,11 +450,16 @@ def test_init_with_type_default_and_live_provided(
             "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
-                "live": {"live": {"html": True, "summary": True}},
-                "metrics": [{"metrics.json": {"cache": False}}],
-                "outs": [{"models": {"checkpoint": True}}],
+                "metrics": [
+                    {"live.json": {"cache": False}},
+                    {"metrics.json": {"cache": False}},
+                ],
+                "outs": ["models"],
                 "params": [{"params.yaml": None}],
-                "plots": [{"plots": {"cache": False}}],
+                "plots": [
+                    {os.path.join("live", "scalars"): {"cache": False}},
+                    {"plots": {"cache": False}},
+                ],
             }
         }
     }