Add User-Defined Tools#19434
Conversation
| # and is scoped to to individual user and never adds to global toolbox | ||
| dynamic_tools_manager: DynamicToolManager = depends(DynamicToolManager) | ||
|
|
||
| @router.get("/api/unprivileged_tools") |
There was a problem hiding this comment.
I feel like I would prefer a name like 'user_tools' but if it is a big change - feel free to ignore. Also sorry I'm reviewing by commit so if any of these changes are undone in future commits feel free to ignore.
Also like the last comment - feel free to just dump the dynamic tools API endpoint and replace it with this. I think I like that name better also.
There was a problem hiding this comment.
Absolutely open to changing how we name things, we did already have 3 or 4 different versions when we hacked on this in Berlin. I'll keep that for a last pass when it's nearing completion though.
|
This is amazing. I don't hate any of it. The CWL fields I think we would struggle to fill out with our runtime is the only part that caused significant stress but I didn't see an attempt to fill those out. I would have semantic questions like is name going to be the name or collection identifier, etc.. but I don't think those are details you've tackled yet unless I missed the commit. I would have started with locking tools down at the XML layer and have dozens of test cases around making sure tool action expressions cannot be evaluated, etc.. for unprivileged tools but I understand that part is pretty unsexy and I think there is some chance that having a fully defined model means those things might be completely unreachable and so that might have been unnecessary work. I think we need to at least audit all the features before the final merge. I created a list of things I'd like to see to broken out into smaller PRs to clean up the core as I was reviewing the commits. None of this is essential - if it works, it works - but any of that extra effort would be appreciated and would ease follow up reviews I think and help isolate potential problems.
|
nsoranzo
left a comment
There was a problem hiding this comment.
Suggestions from my current work on the cwl-1.0 branch.
Maybe the way to address this is worrying about documentation. A tool translation guide maybe where each feature from XML is listed (under contents in https://docs.galaxyproject.org/en/master/dev/schema.html) and how to port it to YAML and if there are any security considerations. I did a lot of work in syncing XSD and YAML model docs in #18787 - I think we will want something like that for the broader tools right? We will need to keep model docs and XSD docs synchronized but also have separate customizations for each. It is kind of a hard problem but worth thinking about and maybe capturing security concerns at this point. |
| hidden: Mapped[Optional[bool]] = mapped_column(default=False) | ||
| active: Mapped[Optional[bool]] = mapped_column(default=True) |
There was a problem hiding this comment.
These 2 columns are also present in "DynamicTool", is the duplication because the plan is to make DynamicTools sharable by associating multiple user ids to the same tool id?
There was a problem hiding this comment.
Right, DynamicTool contains the actual tool representation, and might be created by an admin, and those are globally available if the public flag is set. The private, user defined tools also use DynamicTool to store the representation (with public=False), but ownership and access is managed through UserDynamicToolAssociation. The same DynamicTool can be associated to multiple UserDynamicToolAssociations, that's why I think we should manage active and hidden on the association.
There was a problem hiding this comment.
Thanks for the explanation! I find the 5 properties a bit confusing and I fear the overlap may lead to future bugs. Do you think we can streamline them and clearly define what each is used for?
E.g.:
DynamicTool.public: Admin-only. If set to True, it makes a user-defined tool visible and executable to all usersDynamicTool.active: Admin-only. If set to False, it makes a user-defined tool not executable by any user (what about visible?)UserDynamicToolAssociation.hidden: User-only: If set to True, makes a user-defined tool not visible (but it can still be executed by the user)
Not sure we need the others? DynamicTool.hidden seems to be covered by public, and UserDynamicToolAssociation.active seems unnecessary as a user should be able to just hide or delete the u.-d. tool they don't want to use any more.
I may well be off track with the above definitions, but hopefully you get my point.
There was a problem hiding this comment.
I can add comments and we can add a hidden flag for UserDynamicToolAssociation if we need it down the road. I am wary of modifying DynamicTool.hidden, this might still be a valid path ? (i.e runnable but hidden)
There was a problem hiding this comment.
Thanks, comments would be great, than we can discuss more if needed!
ec05106 to
a0c1e15
Compare
f8e134d to
01d05c5
Compare
bad3bf7 to
e8979e9
Compare
942aca1 to
f311f7d
Compare
|
As impressive as it is exciting - amazing work @mvdbeek! |
|
A lot of thanks also goes to @mr-c for the initial hackathon, pushing the idea and providing so many lessons from the CWL side! |
|
yooohooo 🎉 |

User-Defined Tools (Beta)
Starting with Galaxy 25.0, users can create their own tools without requiring administrator privileges to install them. These tools are written in YAML, defined through the Galaxy user interface, and stored in the database.
Differences from Standard Galaxy Tools
Standard Galaxy tools are written in XML and have broad access to the Galaxy database and filesystem during the command and configuration file templating phase, which uses the Cheetah templating language.
For example, the following XML tool command section queries the Galaxy database and writes a file to the home directory of the system user running the Galaxy process:
This level of access is acceptable when only administrators install tools. However, allowing regular users to define and execute arbitrary tools requires stricter controls.
To address this, Galaxy now supports a restricted tool language for user-defined tools. This format is modeled after the XML tool definition but replaces Cheetah templating with sandboxed JavaScript expressions that do not have access to the database or filesystem.
Example: Concatenate Files Tool (YAML)
Equivalent Tool in XML:
While the structure is similar, several key differences exist:
class: GalaxyUserToolline to signal the use of the restrictedUserToolSourceschema.containerkey.shell_commandkey, using a string with embedded JavaScript expressions inside $(). In the example above, the expression iterates over the input dataset paths and joins them into a single command string.Enabling User-Defined Tools
To enable this feature:
enable_beta_tool_formats: truein your Galaxy configuration.Custom Tool Executionin the admin user interface.Sharing User-Defined Tools
User-defined tools are private to their creators. However, if a tool is embedded in a workflow, any user who imports that workflow will automatically have the tool created in their account.
These tools can also be exported to disk and loaded like regular tools, enabling instance-wide availability if needed.
Security considerations
User-defined tools share the same security risks as interactive tools..
See https://training.galaxyproject.org/training-material/topics/admin/tutorials/interactive-tools/tutorial.html#securing-interactive-tools for an extended discussion.
While the feature is in beta we recommend that only trusted users are allowed to use this feature.
Limitations
The user-defined tool language is still evolving, and additional safety audits are ongoing.
Current limitations include:
extra_filesdirectory is not supportedTODO
tool_typeso that User Defined Tools can be addressed in job_conf.yml / tpv more easilyHere's a screenshot of the embedded tool editor.
How to test the changes?
(Select all options that apply)
License