@@ -132,7 +132,7 @@ def show_invocation(self, invocation_id):
132
132
url = self ._make_url (invocation_id )
133
133
return self ._get (url = url )
134
134
135
- def rerun_invocation (self , invocation_id : str , inputs_update : Optional [dict ] = None ,
135
+ def rerun_invocation (self , invocation_id : str , remap : bool = False , inputs_update : Optional [dict ] = None ,
136
136
params_update : Optional [dict ] = None , history_id : Optional [str ] = None ,
137
137
history_name : Optional [str ] = None , import_inputs_to_history : bool = False ,
138
138
replacement_params : Optional [dict ] = None , allow_tool_state_corrections : bool = False ,
@@ -144,6 +144,13 @@ def rerun_invocation(self, invocation_id: str, inputs_update: Optional[dict] = N
144
144
:type invocation_id: str
145
145
:param invocation_id: Encoded workflow invocation ID to be rerun
146
146
147
+ :type remap: bool
148
+ :param remap: when ``True``, only failed jobs will be rerun. All other parameters
149
+ for this method will be ignored. Job output(s) will be remapped onto the dataset(s)
150
+ created by the original jobs; if other jobs were waiting for these jobs to finish
151
+ successfully, they will be resumed using the new outputs of the tool runs. When ``False``,
152
+ an entire new invocation will be created, using the other parameters specified.
153
+
147
154
:type inputs_update: dict
148
155
:param inputs_update: If different datasets should be used to the original
149
156
invocation, this should contain a mapping of workflow inputs to the new
@@ -196,6 +203,18 @@ def rerun_invocation(self, invocation_id: str, inputs_update: Optional[dict] = N
196
203
.. note::
197
204
This method can only be used with Galaxy ``release_21.01`` or later.
198
205
"""
206
+ if remap :
207
+ errored_jobs = self .gi .jobs .get_jobs (state = 'error' , invocation_id = invocation_id )
208
+ remap_failures = 0
209
+ for job in errored_jobs :
210
+ try :
211
+ self .gi .jobs .rerun_job (job ['id' ], remap = True )
212
+ except ValueError :
213
+ remap_failures += 1
214
+ if remap_failures :
215
+ raise ValueError (f'remap was set to True, but { remap_failures } out of { len (errored_jobs )} errored jobs could not be remapped.' )
216
+ return None
217
+
199
218
invocation_details = self .show_invocation (invocation_id )
200
219
workflow_id = invocation_details ['workflow_id' ]
201
220
inputs = invocation_details ['inputs' ]
0 commit comments