Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.01] fix for cases where panel elements have to_dict with different signature #5615

Merged
merged 3 commits into from Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/galaxy/tools/toolbox/base.py
Expand Up @@ -927,7 +927,7 @@ def tool_panel_contents(self, trans, **kwds):
if elt:
yield elt

def _get_tool_to_dict(self, trans, tool):
def get_tool_to_dict(self, trans, tool):
"""Return tool's to_dict.
Use cache if present, store to cache otherwise.
Note: The cached tool's to_dict is specific to the calls from toolbox.
Expand All @@ -953,14 +953,19 @@ def to_dict(self, trans, in_panel=True, **kwds):
if in_panel:
panel_elts = list(self.tool_panel_contents(trans, **kwds))
for elt in panel_elts:
rval.append(self._get_tool_to_dict(trans, elt))
# Only use cache for objects that are Tools.
if hasattr(elt, "tool_type"):
rval.append(self.get_tool_to_dict(trans, elt))
else:
kwargs = dict(trans=trans, link_details=True, toolbox=self)
rval.append(elt.to_dict(**kwargs))
else:
filter_method = self._build_filter_method(trans)
for id, tool in self._tools_by_id.items():
tool = filter_method(tool, panel_item_types.TOOL)
if not tool:
continue
rval.append(self._get_tool_to_dict(trans, tool))
rval.append(self.get_tool_to_dict(trans, tool))
return rval

def _lineage_in_panel(self, panel_dict, tool=None, tool_lineage=None):
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/tools/toolbox/panel.py
Expand Up @@ -69,7 +69,7 @@ def copy(self):
copy.elems = self.elems.copy()
return copy

def to_dict(self, trans, link_details=False):
def to_dict(self, trans, link_details=False, toolbox=None):
""" Return a dict that includes section's attributes. """

section_dict = super(ToolSection, self).to_dict()
Expand All @@ -79,7 +79,10 @@ def to_dict(self, trans, link_details=False):
link_details=link_details
)
for elt in self.elems.values():
section_elts.append(elt.to_dict(**kwargs))
if hasattr(elt, "tool_type") and toolbox:
section_elts.append(toolbox.get_tool_to_dict(trans, elt))
else:
section_elts.append(elt.to_dict(**kwargs))
section_dict['elems'] = section_elts

return section_dict
Expand Down