Skip to content

Commit

Permalink
Progress on workflow default files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Nov 1, 2023
1 parent 5f4779c commit 742f8d8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 11 deletions.
48 changes: 40 additions & 8 deletions lib/galaxy/tool_util/xsd/galaxy.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4123,7 +4123,8 @@ dataset for the contained input of the type specified using the ``type`` tag.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:group ref="ParamDefaultCollectionElement" minOccurs="0" maxOccurs="unbounded"/>
<!-- can have zero or one collection elements -->
<xs:element name="element" type="ParamDefaultElement" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="collection_type" type="CollectionType" use="optional">
<xs:annotation>
Expand All @@ -4135,21 +4136,52 @@ collection types (the most common types are ``list``, ``paired``,
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="location" type="xs:string" use="optional">

<xs:attribute name="location" type="xs:anyURI" gxdocs:added="23.2" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
Galaxy-aware URI for the default file.
Galaxy-aware URI for the default file. This should only be used with parameters of type "data".
]]></xs:documentation>
</xs:annotation>
</xs:attribute>

</xs:complexType>

<xs:group name="ParamDefaultCollectionElement">
<xs:choice>
<xs:element name="element" type="OutputData" />
</xs:choice>
</xs:group>
<xs:complexType name="ParamDefaultCollection">
<xs:sequence>
<xs:element name="element" type="ParamDefaultElement" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>

<xs:attribute name="collection_type" type="CollectionType" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
Collection type for default collection (if param type is data_collection). Simple collection types are
either ``list`` or ``paired``, nested collections are specified as colon separated list of simple
collection types (the most common types are ``list``, ``paired``,
``list:paired``, or ``list:list``).
]]></xs:documentation>
</xs:annotation>
</xs:attribute>

</xs:complexType>

<xs:complexType name="ParamDefaultElement">
<xs:sequence>
<xs:element name="collection" type="ParamDefaultCollection" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="name" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">Name (and element identifier) for this element</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="location" type="xs:anyURI" gxdocs:added="23.2" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
Galaxy-aware URI for the default file for collection element.
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>

<xs:complexType name="ParamOptions">
<xs:annotation>
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/workflow/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@

if TYPE_CHECKING:
from galaxy.schema.invocation import InvocationMessageUnion
from galaxy.workflow.run import WorkflowProgress


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -176,7 +178,7 @@ def to_cwl(value, hda_references, step):
return value


def from_cwl(value, hda_references, progress):
def from_cwl(value, hda_references, progress: WorkflowProgress):
# TODO: turn actual files into HDAs here ... somehow I suppose. Things with
# file:// locations for instance.
if isinstance(value, dict) and "class" in value and "location" in value:
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/workflow/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ def _invoke_step(self, invocation_step: WorkflowInvocationStep) -> Optional[bool


class ModuleInjector(Protocol):
trans: "WorkRequestContext"

def inject(self, step, step_args=None, steps=None, **kwargs):
pass

Expand Down Expand Up @@ -699,6 +701,9 @@ def subworkflow_progress(
when_values=when_values,
)

def raw_to_galaxy(self, value: dict):
return raw_to_galaxy(self.module_injector.trans, value)

def _recover_mapping(self, step_invocation: WorkflowInvocationStep) -> None:
try:
step_invocation.workflow_step.module.recover_mapping(step_invocation, self)
Expand Down
12 changes: 10 additions & 2 deletions test/unit/workflows/test_workflow_progress.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from typing import cast

from galaxy import model
from galaxy.model.base import transaction
from galaxy.util.unittest import TestCase
from galaxy.workflow.run import WorkflowProgress
from galaxy.workflow.run import (
ModuleInjector,
WorkflowProgress,
)
from .workflow_support import (
MockApp,
MockTrans,
yaml_to_model,
)

Expand Down Expand Up @@ -76,7 +82,8 @@ def _setup_workflow(self, workflow_yaml):
self.invocation.workflow = workflow

def _new_workflow_progress(self):
return WorkflowProgress(self.invocation, self.inputs_by_step_id, MockModuleInjector(self.progress), {})
mock_injector: ModuleInjector = cast(ModuleInjector, MockModuleInjector(self.progress))
return WorkflowProgress(self.invocation, self.inputs_by_step_id, mock_injector, {})

def _set_previous_progress(self, outputs):
for i, (step_id, step_value) in enumerate(outputs):
Expand Down Expand Up @@ -242,6 +249,7 @@ def compute_runtime_state(self, step, step_args=None):
class MockModule:
def __init__(self, progress):
self.progress = progress
self.trans = MockTrans()

def decode_runtime_state(self, step, runtime_state):
return True
Expand Down

0 comments on commit 742f8d8

Please sign in to comment.