Tool Runner

The ToolRunner is a helper class to run Galaxy tools using Blinker signals. This allows connect to connect Galaxy with GUI in a decoupled way.

id = "test"
ToolRunner(id, RemoteCommandTool(), lambda: "nova_galaxy_testing", GALAXY_URL, GALAXY_API_KEY)
execution_signal = blinker.signal(get_signal_id(id, Signal.TOOL_COMMAND))
progress_signal = blinker.signal(get_signal_id(id, Signal.PROGRESS))
await execution_signal.send_async(id, command=ToolCommand.START)

The ToolRunner needs a Tool class which it will manage. This class should inherit from the BasicTool and define functions specific to the tool. For example:

class RemoteCommandTool(BasicTool):
    """Class that prepares RemoteCommandTool tool."""

    def __init__(self) -> None:
        super().__init__()

    def prepare_tool(self) -> Tuple[Tool, Parameters]:
        tool_params = Parameters()
        tool = Tool(id="neutrons_remote_command")
        return tool, tool_params

    def get_results(self, tool: Tool) -> bytes:
        outputs = tool.get_results()
        if not outputs:
            raise Exception("no outputs")
        data = outputs.get_dataset("output1")
        return data.get_content()