|
24 | 24 | from galaxy.managers.context import ProvidesUserContext |
25 | 25 | from galaxy.model import ( |
26 | 26 | DynamicTool, |
| 27 | + User, |
27 | 28 | UserDynamicToolAssociation, |
28 | 29 | ) |
29 | 30 | from galaxy.tool_util.cwl import tool_proxy |
30 | 31 | from galaxy.tool_util.parser.yaml import YamlToolSource |
| 32 | +from galaxy.tool_util.toolbox import AbstractToolBox |
31 | 33 | from galaxy.tool_util_models.dynamic_tool_models import ( |
32 | 34 | DynamicToolPayload, |
33 | 35 | DynamicUnprivilegedToolCreatePayload, |
@@ -61,17 +63,13 @@ class ToolRunReference(NamedTuple): |
61 | 63 |
|
62 | 64 |
|
63 | 65 | def get_tool_from_trans(trans: ProvidesUserContext, tool_ref: ToolRunReference) -> Tool: |
64 | | - return get_tool_from_toolbox(trans.app.toolbox, tool_ref) |
| 66 | + return get_tool_from_toolbox(trans.app.toolbox, tool_ref, trans.user) |
65 | 67 |
|
66 | 68 |
|
67 | | -def get_tool_from_toolbox(toolbox, tool_ref: ToolRunReference) -> Tool: |
68 | | - get_kwds = dict( |
69 | | - tool_id=tool_ref.tool_id, |
70 | | - tool_uuid=tool_ref.tool_uuid, |
71 | | - tool_version=tool_ref.tool_version, |
| 69 | +def get_tool_from_toolbox(toolbox: AbstractToolBox, tool_ref: ToolRunReference, user: Optional[User]) -> Tool: |
| 70 | + tool = toolbox.get_tool( |
| 71 | + tool_id=tool_ref.tool_id, tool_uuid=tool_ref.tool_uuid, tool_version=tool_ref.tool_version, user=user |
72 | 72 | ) |
73 | | - |
74 | | - tool = toolbox.get_tool(**get_kwds) |
75 | 73 | if not tool: |
76 | 74 | log.debug(f"Not found tool with kwds [{tool_ref}]") |
77 | 75 | raise exceptions.ToolMissingException("Tool not found.") |
@@ -102,7 +100,7 @@ def get_tool_by_id_or_uuid(self, id_or_uuid: Union[int, str]) -> Union[DynamicTo |
102 | 100 | return self.get_tool_by_uuid(id_or_uuid) |
103 | 101 |
|
104 | 102 | def get_tool_by_uuid(self, uuid: Optional[Union[UUID, str]]): |
105 | | - stmt = select(DynamicTool).where(DynamicTool.uuid == uuid) |
| 103 | + stmt = select(DynamicTool).where(DynamicTool.uuid == uuid, DynamicTool.public == true()) |
106 | 104 | return self.session().scalars(stmt).one_or_none() |
107 | 105 |
|
108 | 106 | def get_tool_by_tool_id(self, tool_id): |
|
0 commit comments