Skip to content

Commit

Permalink
exp init: Replace live section with metrics and plots.
Browse files Browse the repository at this point in the history
Closes #7534
  • Loading branch information
daavoo authored and David de la Iglesia Castro committed Apr 20, 2022
1 parent cc8a0ce commit 17516f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
12 changes: 7 additions & 5 deletions dvc/repo/experiments/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
44 changes: 30 additions & 14 deletions tests/func/experiments/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
],
}
}
}
Expand Down Expand Up @@ -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}}
],
}
}
}
Expand Down Expand Up @@ -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}},
],
}
}
}
Expand Down Expand Up @@ -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}},
],
}
}
}
Expand Down

0 comments on commit 17516f7

Please sign in to comment.