Skip to content

Commit e4136e4

Browse files
Check for previous run
1 parent 5933c2f commit e4136e4

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

dvc/repo/reproduce.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ def reproduce(
9191
targets = self.collect(target, recursive=recursive, graph=active_graph)
9292

9393
ret = []
94+
checked_stages = set()
9495
for target in targets:
95-
stages = _reproduce_stages(active_graph, target, **kwargs)
96+
stages, these_checked_stages = _reproduce_stages(active_graph, target, checked_stages, **kwargs)
9697
ret.extend(stages)
98+
checked_stages.update(these_checked_stages)
9799

98100
return ret
99101

100102

101103
def _reproduce_stages(
102104
G,
103105
stage,
106+
checked_stages,
104107
downstream=False,
105108
ignore_build_cache=False,
106109
single_item=False,
@@ -157,19 +160,22 @@ def _reproduce_stages(
157160
pipeline = nx.dfs_postorder_nodes(G, stage)
158161

159162
result = []
163+
these_checked_stages = []
160164
for st in pipeline:
161-
try:
162-
ret = _reproduce_stage(st, **kwargs)
163-
164-
if len(ret) != 0 and ignore_build_cache:
165-
# NOTE: we are walking our pipeline from the top to the
166-
# bottom. If one stage is changed, it will be reproduced,
167-
# which tells us that we should force reproducing all of
168-
# the other stages down below, even if their direct
169-
# dependencies didn't change.
170-
kwargs["force"] = True
171-
172-
result.extend(ret)
173-
except Exception as exc:
174-
raise ReproductionError(st.relpath) from exc
175-
return result
165+
if st not in checked_stages:
166+
try:
167+
ret = _reproduce_stage(st, **kwargs)
168+
these_checked_stages.append(st)
169+
170+
if len(ret) != 0 and ignore_build_cache:
171+
# NOTE: we are walking our pipeline from the top to the
172+
# bottom. If one stage is changed, it will be reproduced,
173+
# which tells us that we should force reproducing all of
174+
# the other stages down below, even if their direct
175+
# dependencies didn't change.
176+
kwargs["force"] = True
177+
178+
result.extend(ret)
179+
except Exception as exc:
180+
raise ReproductionError(st.relpath) from exc
181+
return result, these_checked_stages

0 commit comments

Comments
 (0)