Skip to content

Commit

Permalink
repro: use dvc.yaml by default (#3747)
Browse files Browse the repository at this point in the history
Note: This does not change default for `pipeline` as
it cannot show multiple DAGs at the same time. If we
are able to show multiple DAGs, we can just default to
`dvc.yaml`.
  • Loading branch information
skshetry authored May 6, 2020
1 parent aa99cc9 commit e383106
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions dvc/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def __init__(self, args):

@property
def default_targets(self):
"""Default targets for `dvc repro` and `dvc pipeline`."""
from dvc.dvcfile import DVC_FILE
"""Default targets for `dvc repro`."""
from dvc.dvcfile import PIPELINE_FILE

msg = "assuming default target '{}'.".format(DVC_FILE)
msg = "assuming default target '{}'.".format(PIPELINE_FILE)
logger.warning(msg)
return [DVC_FILE]
return [PIPELINE_FILE]

# Abstract methods that have to be implemented by any inheritance class
def run(self):
Expand Down
4 changes: 3 additions & 1 deletion dvc/command/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def _write_dot(self, target, commands, outs):
logger.info(dot_file.getvalue())

def run(self):
from dvc.dvcfile import DVC_FILE

if not self.args.targets:
self.args.targets = self.default_targets
self.args.targets = [DVC_FILE]

for target in self.args.targets:
try:
Expand Down
10 changes: 5 additions & 5 deletions tests/func/test_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from dvc.remote.local import LocalRemote
from dvc.repo import Repo as DvcRepo
from dvc.stage import Stage
from dvc.dvcfile import Dvcfile
from dvc.dvcfile import Dvcfile, DVC_FILE
from dvc.stage.exceptions import StageFileDoesNotExistError
from dvc.system import System
from dvc.utils import file_md5
Expand Down Expand Up @@ -407,11 +407,11 @@ def test(self):
self.assertEqual(ret, 0)

ret = main(
["run", "--no-exec", "--single-stage", "-f", "Dvcfile"] + deps
["run", "--no-exec", "--single-stage", "-f", DVC_FILE] + deps
)
self.assertEqual(ret, 0)

ret = main(["repro", "--dry"])
ret = main(["repro", "--dry", DVC_FILE])
self.assertEqual(ret, 0)


Expand Down Expand Up @@ -820,7 +820,7 @@ def test(self):

os.unlink(bar)

ret = main(["repro", "-c", dname])
ret = main(["repro", "-c", dname, DVC_FILE])
self.assertEqual(ret, 0)
self.assertTrue(os.path.isfile(foo))
self.assertTrue(os.path.isfile(bar))
Expand Down Expand Up @@ -1458,7 +1458,7 @@ def repro_dir(tmp_dir, dvc, run_copy):
assert dir_file_copy.read_text() == "dir file content"
stages["dir_file_copy"] = stage

last_stage = tmp_dir / "dir" / "Dvcfile"
last_stage = tmp_dir / "dir" / DVC_FILE
stage = dvc.run(
fname=fspath(last_stage),
deps=[fspath(origin_copy_2), fspath(dir_file_copy)],
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/command/test_repro.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dvc.cli import parse_args
from dvc.command.repro import CmdRepro
from dvc.dvcfile import PIPELINE_FILE

default_arguments = {
"all_pipelines": False,
Expand All @@ -19,7 +20,7 @@ def test_default_arguments(dvc, mocker):
cmd = CmdRepro(parse_args(["repro"]))
mocker.patch.object(cmd.repo, "reproduce")
cmd.run()
cmd.repo.reproduce.assert_called_with("Dvcfile", **default_arguments)
cmd.repo.reproduce.assert_called_with(PIPELINE_FILE, **default_arguments)


def test_downstream(dvc, mocker):
Expand All @@ -28,4 +29,4 @@ def test_downstream(dvc, mocker):
cmd.run()
arguments = default_arguments.copy()
arguments.update({"downstream": True})
cmd.repo.reproduce.assert_called_with("Dvcfile", **arguments)
cmd.repo.reproduce.assert_called_with(PIPELINE_FILE, **arguments)

0 comments on commit e383106

Please sign in to comment.