mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 23:10:10 +01:00
Merge pull request #684 from efiop/master
dvc: reproduce stage if it has no dependencies and has cmd
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user