Tools

The Tool class represents a Galaxy tool. You can run tools, manage their inputs, and retrieve their outputs using nova-galaxy.

with nova_instance.connect() as connection:
    store = connection.get_data_store(name="nova_galaxy_testing")
    store.mark_for_cleanup()
    test_tool = Tool(TEST_TOOL_ID)
    params = Parameters()
    params.add_input("command_mode|command", "fail")
    test_tool.run(data_store=store, params=params)

By default tools will run synchronously. In order to run a tool in an “async” manner, set the wait argument to False.

outputs = test_tool.run(data_store=store, params=Parameters(), wait=False)

Any code after will be executed immediately. Outputs will be None in this case.

You can get the status of the tool in the form of a WorkState (from nova-common library) enum value:

assert test_tool.get_status() == WorkState.ERROR
assert test_tool.get_full_status().details != ""

If a tool has already been run, and you want to get the results/outputs again:

results = test_tool.get_results()

If you have run a tool asynchronously, and at a later point, you want to wait for the tool, you can use the wait_for_results() method:

outputs = test_tool.run(data_store=store, params=Parameters(), wait=False)
# [async run example complete]
assert outputs is None
assert test_tool.get_uid() is not None
test_tool.wait_for_results()
# [get results example]
results = test_tool.get_results()

If you want to stop a tool from running, but keep any existing outputs from the Tool, use the stop() method. If you want to cancel a tool from running and throw away any output from it, use the cancel() method.

You can get any current stdout and stderr from a Tool with the flexibility of choosing starting position and how many characters you want:

stdout = test_tool.get_stdout()
stdout_substring = test_tool.get_stdout(5, 50)

These methods work regardless of whether the job is running or has been completed.

Advanced users may find they need to access the underlying job id for a tool, which they can do so with get_uid(). Tools can also be assigned to already running or completed jobs by using assign_id()