Skip to content

Commit 4012134

Browse files
committed
Merge branch 'release_26.0' into dev
2 parents 26ce47d + 657196d commit 4012134

File tree

6 files changed

+104
-9
lines changed

6 files changed

+104
-9
lines changed

lib/galaxy/tool_shed/util/shed_util_common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import re
3+
from urllib.parse import quote
34

45
from galaxy import util
56
from galaxy.tool_shed.util import repository_util
@@ -149,7 +150,10 @@ def set_image_paths(app, text, encoded_repository_id=None, tool_shed_repository=
149150
# We're in the tool shed.
150151
route_to_images = f"/repository/static/images/{encoded_repository_id}"
151152
elif tool_shed_repository and tool_id and tool_version:
152-
route_to_images = f"shed_tool_static/{tool_shed_repository.tool_shed}/{tool_shed_repository.owner}/{tool_shed_repository.name}/{tool_id}/{tool_version}"
153+
route_to_images = quote(
154+
f"shed_tool_static/{tool_shed_repository.tool_shed}/{tool_shed_repository.owner}/{tool_shed_repository.name}/{tool_id}/{tool_version}",
155+
safe="/",
156+
)
153157
else:
154158
raise Exception(
155159
"encoded_repository_id or tool_shed_repository and tool_id and tool_version must be provided"

lib/galaxy/tools/parameters/basic.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,15 +2451,25 @@ def append_ldda(ldda):
24512451
# Route each to the correct options list by type so the client can
24522452
# match them by id *and* src.
24532453
for value in job_input_values:
2454-
if isinstance(value, (HistoryDatasetCollectionAssociation, HistoryDatasetAssociation)):
2454+
if isinstance(value, HistoryDatasetCollectionAssociation):
2455+
# HDCAs are handled by the dataset collections section below;
2456+
# only add here if not visible in the current history.
2457+
if value.deleted or not value.visible or value.history != history:
2458+
if value.deleted:
2459+
state = "deleted"
2460+
elif not value.visible:
2461+
state = "hidden"
2462+
else:
2463+
state = "not in current history"
2464+
append(d["options"]["hdca"], value, f"({state}) {value.name}", "hdca", True)
2465+
elif isinstance(value, HistoryDatasetAssociation):
24552466
if value.deleted:
24562467
state = "deleted"
24572468
elif not value.visible:
24582469
state = "hidden"
24592470
else:
24602471
state = "not in current history"
2461-
src = "hdca" if isinstance(value, HistoryDatasetCollectionAssociation) else "hda"
2462-
append(d["options"][src], value, f"({state}) {value.name}", src, True)
2472+
append(d["options"]["hda"], value, f"({state}) {value.name}", "hda", True)
24632473
elif isinstance(value, DatasetCollectionElement):
24642474
append_dce(value)
24652475
elif isinstance(value, LibraryDatasetDatasetAssociation):

lib/galaxy/tools/parameters/dynamic_options.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,10 @@ def _get_ref_data(other_values, ref_name):
10791079
if is_runtime_value(ref):
10801080
return []
10811081
raise ValueError
1082-
if isinstance(ref, DatasetCollectionElement) and ref.hda:
1083-
ref = ref.hda
1082+
if isinstance(ref, DatasetCollectionElement):
1083+
return ref.dataset_instances
10841084
if isinstance(ref, (DatasetFilenameWrapper, HistoryDatasetAssociation, LibraryDatasetDatasetAssociation)):
1085-
ref = [ref]
1085+
return [ref]
10861086
elif isinstance(ref, HistoryDatasetCollectionAssociation):
1087-
ref = ref.to_hda_representative(multiple=True)
1087+
return ref.to_hda_representative(multiple=True)
10881088
return ref

lib/galaxy/webapps/galaxy/controllers/shed_tool_static.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import os
33

44
from galaxy import web
5-
from galaxy.exceptions import RequestParameterInvalidException
5+
from galaxy.exceptions import (
6+
ObjectNotFound,
7+
RequestParameterInvalidException,
8+
)
69
from galaxy.util.path import (
710
join,
811
safe_contains,
@@ -34,6 +37,8 @@ def index(self, trans, shed, owner, repo, tool, version, image_file, **kwargs):
3437
"""
3538
guid = "/".join((shed, "repos", owner, repo, tool, version))
3639
tool = trans.app.toolbox.get_tool(guid)
40+
if tool is None:
41+
raise ObjectNotFound(f"Could not find tool with guid '{guid}'.")
3742
repo_path = os.path.abspath(tool._repository_dir)
3843
found_path = None
3944

lib/galaxy_test/api/test_tools.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,26 @@ def test_build_request_dbkey_filter_unset(self):
286286
assert "hg18_value" in option_values
287287
assert "mm10_value" in option_values
288288

289+
@skip_without_tool("dbkey_filter_collection_input")
290+
def test_run_dbkey_filter_nested_collection_dce(self):
291+
with self.dataset_populator.test_history() as history_id:
292+
list_list = self.dataset_collection_populator.create_list_of_list_in_history(history_id, wait=True).json()
293+
# Set dbkey on the datasets in the inner list
294+
for outer_element in list_list["elements"]:
295+
for inner_element in outer_element["object"]["elements"]:
296+
hda_id = inner_element["object"]["id"]
297+
self.dataset_populator._put(
298+
f"histories/{history_id}/contents/{hda_id}", {"genome_build": "hg19"}, json=True
299+
)
300+
# Get DCE ID of the inner list element - this is a DatasetCollectionElement
301+
# wrapping a child collection (not an HDA)
302+
dce_id = list_list["elements"][0]["id"]
303+
inputs = {
304+
"inputs": {"src": "dce", "id": dce_id},
305+
"index": "hg19_value",
306+
}
307+
self._run("dbkey_filter_collection_input", history_id, inputs, assert_ok=True)
308+
289309
@skip_without_tool("cheetah_problem_unbound_var_input")
290310
def test_legacy_biotools_xref_injection(self):
291311
url = self._api_url("tools/cheetah_problem_unbound_var_input")
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from types import SimpleNamespace
2+
3+
from galaxy.tool_shed.util.shed_util_common import set_image_paths
4+
5+
6+
def test_set_image_paths_encodes_special_characters_in_tool_id():
7+
tool_shed_repository = SimpleNamespace(
8+
tool_shed="toolshed.g2.bx.psu.edu",
9+
owner="devteam",
10+
name="emboss_5",
11+
)
12+
text = ".. image:: static/images/isochore.png"
13+
result = set_image_paths(
14+
app=None,
15+
text=text,
16+
tool_shed_repository=tool_shed_repository,
17+
tool_id="EMBOSS: isochore47",
18+
tool_version="5.0.0.1",
19+
)
20+
assert "EMBOSS%3A%20isochore47" in result
21+
assert "EMBOSS: isochore47" not in result
22+
23+
24+
def test_set_image_paths_preserves_slashes_in_route():
25+
tool_shed_repository = SimpleNamespace(
26+
tool_shed="toolshed.g2.bx.psu.edu",
27+
owner="devteam",
28+
name="emboss_5",
29+
)
30+
text = ".. image:: isochore.png"
31+
result = set_image_paths(
32+
app=None,
33+
text=text,
34+
tool_shed_repository=tool_shed_repository,
35+
tool_id="isochore",
36+
tool_version="5.0.0",
37+
)
38+
assert "shed_tool_static/toolshed.g2.bx.psu.edu/devteam/emboss_5/isochore/5.0.0/" in result
39+
40+
41+
def test_set_image_paths_does_not_modify_http_urls():
42+
tool_shed_repository = SimpleNamespace(
43+
tool_shed="toolshed.g2.bx.psu.edu",
44+
owner="devteam",
45+
name="emboss_5",
46+
)
47+
text = ".. image:: https://example.com/image.png"
48+
result = set_image_paths(
49+
app=None,
50+
text=text,
51+
tool_shed_repository=tool_shed_repository,
52+
tool_id="mytool",
53+
tool_version="1.0",
54+
)
55+
assert ".. image:: https://example.com/image.png" in result
56+
assert "shed_tool_static" not in result

0 commit comments

Comments
 (0)