Merge pull request #684 from efiop/master

dvc: reproduce stage if it has no dependencies and has cmd
This commit is contained in:
Ruslan Kuprieiev
2018-04-29 17:49:30 +03:00
committed by GitHub
2 changed files with 20 additions and 0 deletions
+4
View File
@@ -92,6 +92,10 @@ class Stage(object):
def changed(self):
ret = False
if not self.is_data_source and len(self.deps) == 0:
ret = True
for entry in itertools.chain(self.outs, self.deps):
if entry.changed():
ret = True
+16
View File
@@ -28,6 +28,22 @@ class TestRepro(TestDvc):
cmd='python {} {} {}'.format(self.CODE, self.FOO, self.file1))
class TestReproNoDeps(TestRepro):
def test(self):
out = 'out'
code_file = 'out.py'
stage_file = 'out.dvc'
code = 'import uuid\nwith open("{}", "w+") as fd:\n\tfd.write(str(uuid.uuid4()))\n'.format(out)
with open(code_file, 'w+') as fd:
fd.write(code)
self.dvc.run(fname=stage_file,
outs=[out],
cmd='python {}'.format(code_file))
stages = self.dvc.reproduce(stage_file)
self.assertEqual(len(stages), 1)
class TestReproForce(TestRepro):
def test(self):
stages = self.dvc.reproduce(self.file1_stage, force=True)