Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp init: ask for command before paths #6872

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions dvc/repo/experiments/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ def init_interactive(
show_tree: bool = False,
live: bool = False,
) -> Dict[str, str]:
primary = lremove(
provided.keys(), ["cmd", "code", "data", "models", "params"]
)
command = provided.pop("cmd", None)
primary = lremove(provided.keys(), ["code", "data", "models", "params"])
secondary = lremove(
provided.keys(), ["live"] if live else ["metrics", "plots"]
)

ret: Dict[str, str] = {}

if not (primary or secondary):
if not (command or primary or secondary):
return ret

message = ui.rich_text.assemble(
Expand All @@ -148,6 +146,13 @@ def init_interactive(
)
ui.error_write(message, doc_link, "", sep="\n", styled=True)

if not command:
ret.update(_prompts(["cmd"], defaults))
ui.write()
else:
ret.update({"cmd": command})

ui.write("Enter the paths for dependencies and outputs of the command.")
if show_tree:
from rich.tree import Tree

Expand All @@ -156,7 +161,6 @@ def init_interactive(
highlight=True,
)
workspace = {**defaults, **provided}
workspace.pop("cmd", None)
if not live and "live" not in provided:
workspace.pop("live", None)
for value in sorted(workspace.values()):
Expand Down