Skip to content

Commit

Permalink
Workflow tool state...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jul 25, 2024
1 parent 06afe0a commit d738ebc
Show file tree
Hide file tree
Showing 18 changed files with 985 additions and 30 deletions.
44 changes: 44 additions & 0 deletions doc/source/dev/tool_state_state_classes.plantuml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions doc/source/dev/tool_state_state_classes.plantuml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,35 @@ state_representation = "job_internal"
}
note bottom: Object references of the form \n{src: "hda", id: <decoded_id>}.\n Mapping constructs expanded out.\n (Defaults are inserted?)

class TestCaseToolState {
state_representation = "test_case"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
}
note bottom: Object references of the form file name and URIs.\n Mapping constructs not allowed.\n

class WorkflowStepToolState {
state_representation = "workflow_step"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
}
note bottom: Nearly everything optional except conditional discriminators.\n

class WorkflowStepLinkedToolState {
state_representation = "workflow_step_linked"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
}
note bottom: Expect pre-process ``in`` dictionaries and bring in representation\n of links and defaults and validate them in model.\n

ToolState <|-- RequestToolState
ToolState <|-- RequestInternalToolState
ToolState <|-- JobInternalToolState
ToolState <|-- TestCaseToolState
ToolState <|-- WorkflowStepToolState
ToolState <|-- WorkflowStepLinkedToolState

RequestToolState - RequestInternalToolState : decode >

RequestInternalToolState o-- JobInternalToolState : expand >

WorkflowStepToolState o-- WorkflowStepLinkedToolState : preprocess_links_and_defaults >
}
@enduml
8 changes: 8 additions & 0 deletions lib/galaxy/tool_util/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@
validate_internal_request,
validate_request,
validate_test_case,
validate_workflow_step,
validate_workflow_step_linked,
)
from .state import (
JobInternalToolState,
RequestInternalToolState,
RequestToolState,
TestCaseToolState,
ToolState,
WorkflowStepLinkedToolState,
WorkflowStepToolState,
)
from .visitor import visit_input_values

Expand Down Expand Up @@ -89,6 +93,8 @@
"validate_internal_request",
"validate_request",
"validate_test_case",
"validate_workflow_step",
"validate_workflow_step_linked",
"ToolState",
"TestCaseToolState",
"ToolParameterT",
Expand All @@ -98,4 +104,6 @@
"visit_input_values",
"decode",
"encode",
"WorkflowStepToolState",
"WorkflowStepLinkedToolState",
)
7 changes: 6 additions & 1 deletion lib/galaxy/tool_util/parameters/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
)


def optional(type: Type) -> Type:
return_type: Type = Optional[type] # type: ignore[assignment]
return return_type


def optional_if_needed(type: Type, is_optional: bool) -> Type:
return_type: Type = type
if is_optional:
return_type = Optional[type] # type: ignore[assignment]
return_type = optional(type)
return return_type


Expand Down
12 changes: 2 additions & 10 deletions lib/galaxy/tool_util/parameters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
RulesParameterModel,
SectionParameterModel,
SelectParameterModel,
cond_test_parameter_default_value,
TextParameterModel,
ToolParameterBundle,
ToolParameterBundleModel,
Expand Down Expand Up @@ -155,16 +156,7 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT:
test_param_input_source = input_source.parse_test_input_source()
test_parameter = _from_input_source_galaxy(test_param_input_source)
whens = []
default_value = object()
if isinstance(test_parameter, BooleanParameterModel):
default_value = test_parameter.value
elif isinstance(test_parameter, SelectParameterModel):
select_parameter = cast(SelectParameterModel, test_parameter)
select_default_value = select_parameter.default_value
if select_default_value is not None:
default_value = select_default_value

# TODO: handle select parameter model...
default_value = cond_test_parameter_default_value(test_parameter)
for value, case_inputs_sources in input_source.parse_when_input_sources():
if isinstance(test_parameter, BooleanParameterModel):
# TODO: investigate truevalue/falsevalue when...
Expand Down
Loading

0 comments on commit d738ebc

Please sign in to comment.