@@ -11,3 +11,55 @@ The `Parameters` class is used to define the input parameters for a Galaxy tool.
:dedent:
You can remove an existing input value with `remove_input()` or change the value with `change_input_value()`.
Workflow Parameters
-------------------
The `WorkflowParameters` class is specifically designed for passing inputs and parameters to Galaxy workflows. It provides a more explicit, bioblend-style approach to define workflow-level inputs and parameters for individual steps within a workflow.
**Workflow-level Inputs (`add_workflow_input`)**
Use `add_workflow_input` to provide values for the overall workflow inputs, which are typically identified by numerical IDs (e.g., "0", "1") as defined in the workflow. These can be datasets, dataset collections, or simple values.
.. code-block:: python
from nova.galaxy.parameters import WorkflowParameters
from nova.galaxy.dataset import Dataset, DatasetCollection
workflow_params = WorkflowParameters()
# Adding a dataset as a workflow input (input ID "0")
Use `add_step_param` to set parameters for specific steps within the workflow. These are identified by the step's ID (e.g., "2", "4") and a parameter path (e.g., "input", "series_0|input_mode|export_folder").
.. code-block:: python
from nova.galaxy.parameters import WorkflowParameters
from nova.galaxy.dataset import Dataset
workflow_params = WorkflowParameters()
# Setting a parameter for step "2" with parameter path "input"
# This could be a dataset, dataset collection, or simple value
@@ -35,36 +35,44 @@ To start, you need the ID of the Galaxy workflow you want to run.
Running a Workflow
~~~~~~~~~~~~~~~~~~
To run the workflow, you use the ``run()`` method. This method requires a ``Datastore`` (representing the Galaxy history) and optionally a ``Parameters`` object for inputs.
To run the workflow, you use the ``run()`` method. This method requires a ``Datastore`` (representing the Galaxy history) and optionally a ``WorkflowParameters`` object for inputs and step-specific parameters.
.. code-block:: python
from nova.galaxy.data_store import Datastore
from nova.galaxy.parameters import Parameters
from nova.galaxy.dataset import Dataset # Assuming you have an input dataset
from nova.galaxy.parameters import WorkflowParameters
from nova.galaxy.dataset import Dataset, DatasetCollection
# Assume 'galaxy_connection' is an established Connection object
# Assume 'history_id' is the ID of the target Galaxy history
@@ -147,27 +155,27 @@ Each workflow run (invocation) has a unique ID in Galaxy. You can retrieve this
if invocation_id:
print(f"Galaxy Invocation ID: {invocation_id}")
Accessing Step-Level Jobs
~~~~~~~~~~~~~~~~~~~~~~~~~
Accessing Step-Level Tools
~~~~~~~~~~~~~~~~~~~~~~~~~~
Workflows are composed of individual tool executions (jobs). You can access these as ``Job`` objects using ``get_step_jobs()``. This is useful for monitoring progress at a finer grain or retrieving logs from specific steps.
Workflows are composed of individual tool executions. You can access these as ``Tool`` objects using ``get_step_jobs()``. This is useful for monitoring progress at a finer grain or retrieving logs from specific steps.
print(f" Tool Error Details: {full_tool_status.details if full_tool_status else 'N/A'}")
Important Notes
---------------
* **Workflow Definition**: The structure of your ``Parameters`` object (input labels, step labels for parameters) must match how the workflow is defined in Galaxy. Use the Galaxy UI or API to inspect your workflow's inputs and step details.
* **Workflow Definition**: The structure of your ``WorkflowParameters`` object (workflow input IDs, step IDs, and parameter paths) must match how the workflow is defined in Galaxy. Use the Galaxy UI or API to inspect your workflow's inputs and step details.
* **Dataset IDs**: When providing ``Dataset`` or ``DatasetCollection`` objects as inputs, they must already exist in the Galaxy history and have their ``id`` attribute populated.
* **Error Handling**: Always wrap ``run()`` calls (especially with ``wait=True``) in try-except blocks to handle potential exceptions during workflow execution. Check ``get_full_status().details`` for more information on errors.
* **State Management**: The ``Workflow`` object primarily manages the state of its *last* invocation. If you need to manage multiple concurrent runs of the same workflow definition, instantiate a new ``Workflow`` object for each run.