@@ -91,16 +91,19 @@ def reproduce(
91
91
targets = self .collect (target , recursive = recursive , graph = active_graph )
92
92
93
93
ret = []
94
+ checked_stages = set ()
94
95
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 )
96
97
ret .extend (stages )
98
+ checked_stages .update (these_checked_stages )
97
99
98
100
return ret
99
101
100
102
101
103
def _reproduce_stages (
102
104
G ,
103
105
stage ,
106
+ checked_stages ,
104
107
downstream = False ,
105
108
ignore_build_cache = False ,
106
109
single_item = False ,
@@ -157,19 +160,22 @@ def _reproduce_stages(
157
160
pipeline = nx .dfs_postorder_nodes (G , stage )
158
161
159
162
result = []
163
+ these_checked_stages = []
160
164
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