exp init: autostage .gitignores, dvc.yaml and params file

This commit is contained in:
Saugat Pachhai (सौगात)
2021-11-02 12:00:06 +05:45
committed by Saugat Pachhai
parent 97e97c7f24
commit 208ccb2430
2 changed files with 13 additions and 9 deletions
+9 -7
View File
@@ -224,13 +224,13 @@ def init(
assert "cmd" in context
params_kv = []
if context.get("params"):
params = context.get("params")
if params:
from dvc.utils.serialize import LOADERS
path = context["params"]
assert isinstance(path, str)
_, ext = os.path.splitext(path)
params_kv = [{path: list(LOADERS[ext](path))}]
assert isinstance(params, str)
_, ext = os.path.splitext(params)
params_kv = [{params: list(LOADERS[ext](params))}]
checkpoint_out = bool(context.get("live"))
models = context.get("models")
@@ -255,9 +255,11 @@ def init(
if not interactive or ui.confirm(
"Do you want to add the above contents to dvc.yaml?"
):
with _disable_logging():
scm = repo.scm
with _disable_logging(), scm.track_file_changes(autostage=True):
stage.dump(update_lock=False)
stage.ignore_outs()
stage.ignore_outs()
scm.track_file(params)
else:
raise DvcException("Aborting ...")
return stage
+4 -2
View File
@@ -183,8 +183,10 @@ class Base:
"""
@contextmanager
def track_file_changes(self, config=None):
autostage = get_in(config or {}, ["core", "autostage"])
def track_file_changes(self, config=None, autostage=False):
autostage = get_in(
config or {}, ["core", "autostage"], default=autostage
)
try:
yield