mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
fix UI message
This commit is contained in:
committed by
Saugat Pachhai
parent
69ce69e427
commit
6eb5c31dd7
@@ -69,7 +69,6 @@ class CmdExperimentsInit(CmdBase):
|
||||
)
|
||||
|
||||
text = ui.rich_text.assemble(
|
||||
"\n" if self.args.interactive else "",
|
||||
"Created ",
|
||||
(self.args.name, "bright_blue"),
|
||||
" stage in ",
|
||||
|
||||
@@ -215,7 +215,7 @@ def is_file(path: str) -> bool:
|
||||
return bool(ext)
|
||||
|
||||
|
||||
def init_deps(stage: PipelineStage, log: bool = False) -> None:
|
||||
def init_deps(stage: PipelineStage) -> None:
|
||||
from funcy import rpartial
|
||||
|
||||
from dvc.dependency import ParamsDependency
|
||||
@@ -224,7 +224,7 @@ def init_deps(stage: PipelineStage, log: bool = False) -> None:
|
||||
new_deps = [dep for dep in stage.deps if not dep.exists]
|
||||
params, deps = lsplit(rpartial(isinstance, ParamsDependency), new_deps)
|
||||
|
||||
if log:
|
||||
if new_deps:
|
||||
paths = map("[green]{0}[/]".format, new_deps)
|
||||
ui.write(f"Creating {humanize.join(paths)}", styled=True)
|
||||
|
||||
@@ -319,23 +319,26 @@ def init(
|
||||
|
||||
from dvc.ui.prompt import Confirm
|
||||
|
||||
if not interactive or Confirm.ask(
|
||||
if interactive and not Confirm.ask(
|
||||
"Do you want to add the above contents to dvc.yaml?",
|
||||
console=ui.error_console,
|
||||
default=True,
|
||||
stream=stream,
|
||||
):
|
||||
with _disable_logging(), repo.scm_context(autostage=True, quiet=True):
|
||||
stage.dump(update_lock=False)
|
||||
stage.ignore_outs()
|
||||
if not interactive:
|
||||
label = "Using experiment project structure:"
|
||||
display_workspace_tree(context, label)
|
||||
init_deps(stage, log=not interactive)
|
||||
if params:
|
||||
repo.scm_context.track_file(params)
|
||||
else:
|
||||
raise DvcException("Aborting ...")
|
||||
|
||||
if interactive:
|
||||
ui.error_write() # add a newline after the prompts
|
||||
|
||||
with _disable_logging(), repo.scm_context(autostage=True, quiet=True):
|
||||
stage.dump(update_lock=False)
|
||||
stage.ignore_outs()
|
||||
if not interactive:
|
||||
label = "Using experiment project structure:"
|
||||
display_workspace_tree(context, label)
|
||||
init_deps(stage)
|
||||
if params:
|
||||
repo.scm_context.track_file(params)
|
||||
|
||||
assert isinstance(stage, PipelineStage)
|
||||
return stage
|
||||
|
||||
@@ -213,7 +213,7 @@ def test_init_interactive_params_validation(tmp_dir, dvc, capsys):
|
||||
"Please retry with an existing parameters file.\n"
|
||||
"Path to a parameters file [params.yaml, n to omit]:"
|
||||
) in err
|
||||
assert not out
|
||||
assert out == "Creating script.py\n"
|
||||
|
||||
|
||||
def test_init_with_no_defaults_interactive(tmp_dir, dvc):
|
||||
@@ -296,9 +296,8 @@ def test_init_default(tmp_dir, scm, dvc, interactive, overrides, inp, capsys):
|
||||
if interactive:
|
||||
assert "'script.py' does not exist, the file will be created." in err
|
||||
assert "'data' does not exist, the directory will be created." in err
|
||||
assert not out
|
||||
return
|
||||
assert "Using experiment project structure: " in out
|
||||
else:
|
||||
assert "Using experiment project structure: " in out
|
||||
assert "Creating script.py and data" in out
|
||||
|
||||
|
||||
@@ -383,9 +382,8 @@ def test_init_interactive_live(
|
||||
if interactive:
|
||||
assert "'script.py' does not exist, the file will be created." in err
|
||||
assert "'data' does not exist, the directory will be created." in err
|
||||
assert not out
|
||||
return
|
||||
assert "Using experiment project structure: " in out
|
||||
else:
|
||||
assert "Using experiment project structure: " in out
|
||||
assert "Creating script.py and data" in out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user