Skip to content

Commit 990b11a

Browse files
committed
Fix HistoryClient.show_dataset_provenance() not passing the follow parameter
1 parent 8cfe6f0 commit 990b11a

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@
1212

1313
* Added ``get_or_create_user_apikey()`` method to ``UserClient``.
1414

15+
* Added ``require_exact_tool_versions`` parameter to
16+
``WorkflowClient.invoke_workflow()`` method (thanks to
17+
[cat-bro](https://github.com/cat-bro)).
18+
1519
* Remove unused methods from ``bioblend.config.Config``. If needed, use the
1620
methods inherited from `configparser.ConfigParser` instead.
1721

22+
* Allowed any 2XX HTTP response status code in ``Client._delete()`` to correctly
23+
support history purging via Celery (thanks to
24+
[Nolan Woods](https://github.com/innovate-invent)).
25+
26+
* Fixed bug in ``HistoryClient.show_dataset_provenance()`` where the ``follow``
27+
parameter was not passed to the Galaxy API.
28+
1829
* BioBlend.objects: Added ``delete()`` abstract method to ``DatasetContainer``
1930
class.
2031

bioblend/_tests/GalaxyTestBase.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import os
22
import unittest
3-
from typing import Any
3+
from typing import (
4+
Any,
5+
Dict,
6+
)
7+
8+
from typing_extensions import Literal
49

510
import bioblend
611
from bioblend.galaxy import GalaxyInstance
@@ -30,3 +35,19 @@ def _wait_and_verify_dataset(
3035
) -> None:
3136
dataset_contents = self.gi.datasets.download_dataset(dataset_id, maxwait=timeout_seconds)
3237
assert dataset_contents == expected_contents
38+
39+
def _run_random_lines1(
40+
self, history_id: str, dataset_id: str, input_format: Literal["21.01", "legacy"] = "legacy"
41+
) -> Dict[str, Any]:
42+
tool_inputs = {
43+
"num_lines": "1",
44+
"input": {"src": "hda", "id": dataset_id},
45+
}
46+
if input_format == "21.01":
47+
tool_inputs.update({"seed_source": {"seed_source_selector": "set_seed", "seed": "asdf"}})
48+
else:
49+
# legacy format
50+
tool_inputs.update({"seed_source|seed_source_selector": "set_seed", "seed_source|seed": "asdf"})
51+
return self.gi.tools.run_tool(
52+
history_id=history_id, tool_id="random_lines1", tool_inputs=tool_inputs, input_format=input_format
53+
)

bioblend/_tests/TestGalaxyHistories.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,26 @@ def test_show_dataset(self):
140140
assert not dataset["deleted"]
141141
assert dataset["visible"]
142142

143-
def test_show_dataset_provenance(self):
143+
@test_util.skip_unless_galaxy("release_22.01")
144+
def test_show_dataset_provenance(self) -> None:
145+
MINIMAL_PROV_KEYS = ("id", "uuid")
146+
OTHER_PROV_KEYS = ("job_id", "parameters", "stderr", "stdout", "tool_id")
147+
ALL_PROV_KEYS = MINIMAL_PROV_KEYS + OTHER_PROV_KEYS
144148
history_id = self.history["id"]
145149
dataset1_id = self._test_dataset(history_id)
146-
prov = self.gi.histories.show_dataset_provenance(history_id, dataset1_id)
147-
for key in ["id", "job_id", "parameters", "stderr", "stdout", "tool_id"]:
150+
dataset2_id = self._run_random_lines1(history_id, dataset1_id)["outputs"][0]["id"]
151+
prov = self.gi.histories.show_dataset_provenance(history_id, dataset2_id)
152+
for key in ALL_PROV_KEYS:
148153
assert key in prov
154+
for key in MINIMAL_PROV_KEYS:
155+
assert key in prov["parameters"]["input"]
156+
for key in OTHER_PROV_KEYS:
157+
assert key not in prov["parameters"]["input"]
158+
recursive_prov = self.gi.histories.show_dataset_provenance(history_id, dataset2_id, follow=True)
159+
for key in ALL_PROV_KEYS:
160+
assert key in recursive_prov
161+
for key in ALL_PROV_KEYS:
162+
assert key in recursive_prov["parameters"]["input"]
149163

150164
def test_delete_dataset(self):
151165
history_id = self.history["id"]

bioblend/_tests/TestGalaxyJobs.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,4 @@ def test_cancel_job(self):
227227
assert job["state"] in ("deleted", "deleting")
228228

229229
def _run_tool(self, input_format: Literal["21.01", "legacy"] = "legacy") -> dict:
230-
tool_inputs = {
231-
"num_lines": "1",
232-
"input": {"src": "hda", "id": self.dataset_id},
233-
}
234-
if input_format == "21.01":
235-
tool_inputs.update({"seed_source": {"seed_source_selector": "set_seed", "seed": "asdf"}})
236-
else:
237-
# legacy format
238-
tool_inputs.update({"seed_source|seed_source_selector": "set_seed", "seed_source|seed": "asdf"})
239-
240-
return self.gi.tools.run_tool(
241-
history_id=self.history_id, tool_id="random_lines1", tool_inputs=tool_inputs, input_format=input_format
242-
)
230+
return super()._run_random_lines1(self.history_id, self.dataset_id, input_format=input_format)

bioblend/galaxy/histories/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ def show_dataset_provenance(self, history_id: str, dataset_id: str, follow: bool
426426
'uuid': '5c0c43f5-8d93-44bd-939d-305e82f213c6'}
427427
"""
428428
url = "/".join((self._make_url(history_id, contents=True), dataset_id, "provenance"))
429-
return self._get(url=url)
429+
params = {"follow": follow}
430+
return self._get(url=url, params=params)
430431

431432
def update_history(self, history_id: str, **kwargs: Any) -> Dict[str, Any]:
432433
"""

0 commit comments

Comments
 (0)