Allow workflow inputs to be specifiable by UUID without explicit inputs_by.

Since there is no chance of conflict with step.id or step.order_index, just allow inputs or ds_map respectively to be indexed by UUID.
This commit is contained in:
John Chilton
2014-12-15 22:20:12 -05:00
parent 623d8ce9c9
commit 7c9096ae12
2 changed files with 28 additions and 21 deletions
+21 -19
View File
@@ -53,18 +53,25 @@ def normalize_inputs(steps, inputs, inputs_by):
if step.type not in INPUT_STEP_TYPES:
continue
if inputs_by == "step_id":
inputs_key = str( step.id )
elif inputs_by == "step_index":
inputs_key = str( step.order_index )
elif inputs_by == "step_uuid":
inputs_key = str( step.uuid )
elif inputs_by == "name":
inputs_key = step.tool_inputs.get( 'name', None )
else:
message = "Workflow cannot be run because unexpected inputs_by value specified."
raise exceptions.MessageException( message )
if inputs_key not in inputs:
possible_input_keys = []
for inputs_by_el in inputs_by.split("|"):
if inputs_by_el == "step_id":
possible_input_keys = [str( step.id )]
elif inputs_by_el == "step_index":
possible_input_keys = [str( step.order_index )]
elif inputs_by_el == "step_uuid":
possible_input_keys = [str( step.uuid )]
elif inputs_by_el == "name":
possible_input_keys = [step.tool_inputs.get( 'name', None )]
else:
message = "Workflow cannot be run because unexpected inputs_by value specified."
raise exceptions.MessageException( message )
inputs_key = None
for possible_input_key in possible_input_keys:
if possible_input_key in inputs:
inputs_key = possible_input_key
if not inputs_key:
message = "Workflow cannot be run because an expected input step '%s' has no input dataset." % step.id
raise exceptions.MessageException( message )
@@ -164,18 +171,13 @@ def build_workflow_run_config( trans, workflow, payload ):
# Default to legacy behavior - read ds_map and reference steps
# by unencoded step id (a raw database id).
inputs = payload.get( 'ds_map', {} )
inputs_by = inputs_by or 'step_id'
inputs_by = inputs_by or 'step_id|step_uuid'
else:
inputs = inputs or {}
# New default is to reference steps by index of workflow step
# which is intrinsic to the workflow and independent of the state
# of Galaxy at the time of workflow import.
inputs_by = inputs_by or 'step_index'
# TODO: with a little reworking this default could be
# step_index or step_uuid depending on what is inputs -
# unlike step_id and step_index there is not chance of
# conflicts.
inputs_by = inputs_by or 'step_index|step_uuid'
add_to_history = 'no_add_to_history' not in payload
history_param = payload.get('history', '')
+7 -2
View File
@@ -78,13 +78,14 @@ class BaseWorkflowsApiTestCase( api.ApiTestCase ):
elif inputs_by == "name":
workflow_request[ "inputs" ] = dumps( label_map )
workflow_request[ "inputs_by" ] = 'name'
elif inputs_by == "step_uuid":
elif inputs_by in [ "step_uuid", "uuid_implicitly" ]:
uuid_map = {
workflow["steps"]["0"]["uuid"]: self._ds_entry(hda1),
workflow["steps"]["1"]["uuid"]: self._ds_entry(hda2),
}
workflow_request[ "inputs" ] = dumps( uuid_map )
workflow_request[ "inputs_by" ] = "step_uuid"
if inputs_by == "step_uuid":
workflow_request[ "inputs_by" ] = "step_uuid"
return workflow_request, history_id
@@ -431,6 +432,10 @@ class WorkflowsApiTestCase( BaseWorkflowsApiTestCase ):
def test_run_workflow_by_uuid( self ):
self.__run_cat_workflow( inputs_by='step_uuid' )
@skip_without_tool( "cat1" )
def test_run_workflow_by_uuid_implicitly( self ):
self.__run_cat_workflow( inputs_by='uuid_implicitly' )
@skip_without_tool( "cat1" )
def test_run_workflow_by_name( self ):
self.__run_cat_workflow( inputs_by='name' )