Skip to content

Commit ff15d6c

Browse files
committed
Fix test and add test without updating the parameter input for Galaxy >=21.01
1 parent 0d093bf commit ff15d6c

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

bioblend/_tests/TestGalaxyInvocations.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,23 +175,26 @@ def test_rerun_invocation(self):
175175
history = self.gi.histories.show_history(rerun_invocation["history_id"], contents=True)
176176
assert len(history) == 3
177177

178-
@test_util.skip_unless_galaxy("release_24.02")
178+
@test_util.skip_unless_galaxy("release_21.01")
179179
def test_rerun_invocation_with_input_params(self):
180180
threeline_dataset_id = self._test_dataset(self.history_id, contents="A\nB\nC")
181181
invocation = self._invoke_x_random_lines_workflow(threeline_dataset_id)
182182
self.gi.invocations.wait_for_invocation(invocation["id"])
183-
params = {
184-
"how_many": {
185-
"parameter_value": "1",
186-
"label": "how_many",
187-
}
188-
}
183+
rerun_invocation = self.gi.invocations.rerun_invocation(invocation["id"], history_id=self.history_id)
184+
self.gi.invocations.wait_for_invocation(rerun_invocation["id"])
185+
186+
@test_util.skip_unless_galaxy("release_24.2")
187+
def test_rerun_invocation_with_input_params_changed(self):
188+
threeline_dataset_id = self._test_dataset(self.history_id, contents="A\nB\nC")
189+
invocation = self._invoke_x_random_lines_workflow(threeline_dataset_id)
190+
self.gi.invocations.wait_for_invocation(invocation["id"])
191+
inputs_update = {"how_many": 1}
189192
rerun_invocation = self.gi.invocations.rerun_invocation(
190-
invocation["id"], params_update=params, history_id=self.history_id
193+
invocation["id"], inputs_update=inputs_update, history_id=self.history_id
191194
)
192195
self.gi.invocations.wait_for_invocation(rerun_invocation["id"])
193196
rerun_request = self.gi.invocations.get_invocation_request(rerun_invocation["id"])
194-
assert rerun_request["inputs"]["how_many"] == "1"
197+
assert rerun_request["inputs"]["how_many"] == 1
195198

196199
def _invoke_workflow(self) -> dict[str, Any]:
197200
dataset = {"src": "hda", "id": self.dataset_id}
@@ -213,7 +216,7 @@ def _invoke_pause_workflow(self) -> dict[str, Any]:
213216
def _invoke_x_random_lines_workflow(self, dataset_id: str) -> dict[str, Any]:
214217
return self.gi.workflows.invoke_workflow(
215218
self.x_random_lines_workflow_id,
216-
inputs={"from_what": {"src": "hda", "id": dataset_id}, "how_many": "2"},
219+
inputs={"from_what": {"src": "hda", "id": dataset_id}, "how_many": 2},
217220
history_id=self.history_id,
218221
inputs_by="name",
219222
)

bioblend/galaxy/invocations/__init__.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,32 @@ def rerun_invocation(
250250
raise
251251
# Galaxy release_24.1 or earlier
252252
invocation = self.show_invocation(invocation_id)
253+
workflow_step_id_to_index = {
254+
step["workflow_step_id"]: index for index, step in enumerate(invocation["steps"])
255+
}
256+
# Merge input_step_parameters (indexed by label) into inputs (indexed by step index)
257+
inputs = invocation["inputs"]
258+
for param_input_dict in invocation["input_step_parameters"].values():
259+
workflow_step_id = param_input_dict["workflow_step_id"]
260+
workflow_step_index = workflow_step_id_to_index[workflow_step_id]
261+
inputs[str(workflow_step_index)] = param_input_dict
253262
payload = {
254-
"inputs": invocation["inputs"],
263+
"inputs": inputs,
255264
"instance": True,
256-
"params": invocation["input_step_parameters"],
257265
"workflow_id": invocation["workflow_id"],
258266
}
259267
else:
260268
# Drop history_id from the payload as we will set history later
261269
payload.pop("history_id")
262270
workflow_id = payload["workflow_id"]
263271
if inputs_update:
264-
payload.setdefault("inputs", {}).update(inputs_update)
272+
if payload.get("inputs") is None:
273+
payload["inputs"] = {}
274+
payload["inputs"].update(inputs_update)
265275
if params_update:
266-
payload.setdefault("params", {}).update(params_update)
276+
if payload.get("parameters") is None:
277+
payload["parameters"] = {}
278+
payload["parameters"].update(params_update)
267279
if replacement_params:
268280
payload["replacement_params"] = replacement_params
269281
if history_id:
@@ -407,7 +419,7 @@ def get_invocation_request(self, invocation_id: str) -> dict[str, Any]:
407419
:return: The invocation request.
408420
409421
.. note::
410-
This method works only on Galaxy 24.02 or later.
422+
This method works only on Galaxy 24.2 or later.
411423
"""
412424
url = self._make_url(invocation_id) + "/request"
413425
return self._get(url=url)

0 commit comments

Comments
 (0)