Repository: iterative/dvc

Issue:
exp init: change stage name to `train`
@dberenbaum, with `--dl`, I don't think `dl` as a default stage name makes sense. Maybe we should go with `train` then?

_Originally posted by @skshetry in https://github.com/iterative/dvc/issues/6446#issuecomment-986792458_

Discussion:

Patch:
diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py
index 5aa63e158..b097e9e12 100644
--- a/dvc/command/experiments.py
+++ b/dvc/command/experiments.py
@@ -851,7 +851,7 @@ class CmdExperimentsInit(CmdBase):
             force=self.args.force,
         )
 
-        name = self.args.name or self.args.type
+        name = self.args.name or "train"
 
         text = ui.rich_text.assemble(
             "\n" if self.args.interactive else "",
diff --git a/dvc/repo/experiments/init.py b/dvc/repo/experiments/init.py
index feefa01d0..d0aaa4786 100644
--- a/dvc/repo/experiments/init.py
+++ b/dvc/repo/experiments/init.py
@@ -213,7 +213,7 @@ def init(
     from dvc.dvcfile import make_dvcfile
 
     dvcfile = make_dvcfile(repo, "dvc.yaml")
-    name = name or type
+    name = name or "train"
 
     _check_stage_exists(dvcfile, name, force=force)
 


Test patch:
diff --git a/tests/func/experiments/test_init.py b/tests/func/experiments/test_init.py
index 4aabd049a..1ed59d879 100644
--- a/tests/func/experiments/test_init.py
+++ b/tests/func/experiments/test_init.py
@@ -30,10 +30,10 @@ def test_init_simple(tmp_dir, scm, dvc, capsys):
     assert main(["exp", "init", script]) == 0
     out, err = capsys.readouterr()
     assert not err
-    assert "Created default stage in dvc.yaml" in out
+    assert "Created train stage in dvc.yaml" in out
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": script,
                 "deps": ["data", "src"],
                 "metrics": [{"metrics.json": {"cache": False}}],
@@ -46,38 +46,32 @@ def test_init_simple(tmp_dir, scm, dvc, capsys):
 
 
 @pytest.mark.parametrize("interactive", [True, False])
-@pytest.mark.parametrize("typ", ["default", "live"])
-def test_when_stage_already_exists_with_same_name(
-    tmp_dir, dvc, interactive, typ
-):
-    (tmp_dir / "dvc.yaml").dump({"stages": {typ: {"cmd": "test"}}})
+def test_when_stage_already_exists_with_same_name(tmp_dir, dvc, interactive):
+    (tmp_dir / "dvc.yaml").dump({"stages": {"train": {"cmd": "test"}}})
     with pytest.raises(DuplicateStageName) as exc:
         init(
             dvc,
             interactive=interactive,
-            type=typ,
             overrides={"cmd": "true"},
             defaults=CmdExperimentsInit.DEFAULTS,
         )
     assert (
-        str(exc.value) == f"Stage '{typ}' already exists in 'dvc.yaml'. "
+        str(exc.value) == "Stage 'train' already exists in 'dvc.yaml'. "
         "Use '--force' to overwrite."
     )
 
 
-@pytest.mark.parametrize("typ", ["default", "live"])
-def test_when_stage_force_if_already_exists(tmp_dir, dvc, typ):
+def test_when_stage_force_if_already_exists(tmp_dir, dvc):
     (tmp_dir / "params.yaml").dump({"foo": 1})
-    (tmp_dir / "dvc.yaml").dump({"stages": {typ: {"cmd": "test"}}})
+    (tmp_dir / "dvc.yaml").dump({"stages": {"train": {"cmd": "test"}}})
     init(
         dvc,
-        type=typ,
         force=True,
         overrides={"cmd": "true"},
         defaults=CmdExperimentsInit.DEFAULTS,
     )
     d = (tmp_dir / "dvc.yaml").parse()
-    assert d["stages"][typ]["cmd"] == "true"
+    assert d["stages"]["train"]["cmd"] == "true"
 
 
 def test_with_a_custom_name(tmp_dir, dvc):
@@ -91,7 +85,7 @@ def test_init_with_no_defaults_non_interactive(tmp_dir, scm, dvc):
     init(dvc, defaults={}, overrides={"cmd": "python script.py"})
 
     assert (tmp_dir / "dvc.yaml").parse() == {
-        "stages": {"default": {"cmd": "python script.py"}}
+        "stages": {"train": {"cmd": "python script.py"}}
     }
     scm._reset()
     assert not (tmp_dir / "dvc.lock").exists()
@@ -134,7 +128,7 @@ def test_init_interactive_when_no_path_prompts_need_to_be_asked(
     )
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
                 "live": {"dvclive": {"html": True, "summary": True}},
@@ -159,7 +153,7 @@ def test_when_params_is_omitted_in_interactive_mode(tmp_dir, scm, dvc):
 
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "python script.py",
                 "deps": ["data", "script.py"],
                 "metrics": [{"metrics.json": {"cache": False}}],
@@ -189,7 +183,7 @@ def test_init_interactive_params_validation(tmp_dir, dvc, capsys):
 
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "python script.py",
                 "deps": ["data", "script.py"],
                 "metrics": [{"metrics.json": {"cache": False}}],
@@ -232,7 +226,7 @@ def test_init_with_no_defaults_interactive(tmp_dir, dvc):
     )
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "python script.py",
                 "deps": ["python script.py", "script.py"],
                 "metrics": [{"metric": {"cache": False}}],
@@ -278,7 +272,7 @@ def test_init_interactive_default(
 
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "python script.py",
                 "deps": ["data", "script.py"],
                 "metrics": [{"metrics.json": {"cache": False}}],
@@ -359,7 +353,7 @@ def test_init_interactive_live(
     )
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "dl": {
+            "train": {
                 "cmd": "python script.py",
                 "deps": ["data", "script.py"],
                 "live": {"dvclive": {"html": True, "summary": True}},
@@ -403,7 +397,7 @@ def test_init_with_type_live_and_models_plots_provided(
     )
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "dl": {
+            "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
                 "live": {"dvclive": {"html": True, "summary": True}},
@@ -436,7 +430,7 @@ def test_init_with_type_default_and_live_provided(
     )
     assert (tmp_dir / "dvc.yaml").parse() == {
         "stages": {
-            "default": {
+            "train": {
                 "cmd": "cmd",
                 "deps": ["data", "src"],
                 "live": {"live": {"html": True, "summary": True}},
diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py
index c256c2184..8a3681d7c 100644
--- a/tests/unit/command/test_experiments.py
+++ b/tests/unit/command/test_experiments.py
@@ -628,7 +628,7 @@ def test_experiments_init(dvc, scm, mocker, capsys, extra_args):
         interactive=False,
         force=False,
     )
-    expected = "Created default stage in dvc.yaml."
+    expected = "Created train stage in dvc.yaml."
     if not extra_args:
         expected += (
             ' To run, use "dvc exp run".\n'