Skip to content

Commit

Permalink
Inject data module values in connected steps on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Aug 1, 2016
1 parent d8c22b7 commit 9f75926
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
12 changes: 7 additions & 5 deletions client/galaxy/scripts/mvc/tool/tool-form-composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
errors : step.messages,
initial_errors : true,
cls : 'ui-portlet-narrow',
hide_operations : true
hide_operations : true,
needs_refresh : false,
always_refresh : step.step_type != 'tool'
}, step );
self.steps[ i ] = step;
self.links[ i ] = [];
Expand Down Expand Up @@ -205,9 +207,7 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
if ( !_.isEmpty( this.wp_inputs ) ) {
this.wp_form = new Form({ title: '<b>Workflow Parameters</b>', inputs: this.wp_inputs, cls: 'ui-portlet-narrow', onchange: function() {
_.each( self.wp_form.input_list, function( input_def, i ) {
_.each( input_def.links, function( step ) {
self._refreshStep( step );
});
_.each( input_def.links, function( step ) { self._refreshStep( step ) } );
});
}
});
Expand Down Expand Up @@ -276,7 +276,7 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
self._append( self.$steps, form.$el );
}
self.forms[ i ] = form;
self._refreshStep( step );
step.needs_refresh && self._refreshStep( step );
self._resolve( form.deferred, promise );
self.execute_btn.model.set( 'percentage', ( i + 1 ) * 100.0 / self.steps.length );
Galaxy.emit.debug( 'tool-form-composite::initialize()', i + ' : Workflow step state ready.', step );
Expand Down Expand Up @@ -327,6 +327,8 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
}
});
form.trigger( 'change' );
} else {
step.needs_refresh = true;
}
},

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/controllers/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def run( self, trans, id, history_id=None, hide_fixed_params=False, **kwargs ):
trans.workflow_building_mode = workflow_building_modes.USE_HISTORY
for step in workflow.steps:
try:
module_injector.inject( step )
module_injector.inject( step, steps=workflow.steps )
except MissingToolException:
if step.tool_id not in missing_tools:
missing_tools.append(step.tool_id)
Expand Down
28 changes: 18 additions & 10 deletions lib/galaxy/workflow/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def check_and_update_state( self ):
"""
pass

def add_dummy_datasets( self, connections=None):
def add_dummy_datasets( self, connections=None, steps=None ):
# Replaced connected inputs with DummyDataset values.
pass

Expand Down Expand Up @@ -417,7 +417,7 @@ def check_and_update_state( self ):
"""
return None

def add_dummy_datasets( self, connections=None):
def add_dummy_datasets( self, connections=None, steps=None ):
# Replaced connected inputs with DummyDataset values.
return None

Expand Down Expand Up @@ -1139,22 +1139,30 @@ def _handle_post_job_actions( self, step, job, replacement_dict ):
if flush_required:
self.trans.sa_session.flush()

def add_dummy_datasets( self, connections=None):
def add_dummy_datasets( self, connections=None, steps=None ):
if connections:
# Store onnections by input name
input_connections_by_name = \
dict( ( conn.input_name, conn ) for conn in connections )
input_connections_by_name = dict( ( conn.input_name, conn ) for conn in connections )
else:
input_connections_by_name = {}

# Any connected input needs to have value RuntimeValue (these
# are not persisted so we need to do it every time)
def callback( input, prefixed_name, context, **kwargs ):
if isinstance( input, DataToolParameter ) or isinstance( input, DataCollectionToolParameter ):
if connections is None or prefixed_name in input_connections_by_name:
if self.trans.workflow_building_mode is workflow_building_modes.USE_HISTORY:
if connections is None or prefixed_name in input_connections_by_name:
if steps:
connection = input_connections_by_name[ prefixed_name ]
output_step = next( output_step for output_step in steps if connection.output_step_id == output_step.id )
if output_step.type.startswith( 'data' ):
output_inputs = output_step.module.get_runtime_inputs()
return output_inputs[ 'input' ].get_initial_value( self.trans, context )
return RuntimeValue()
else:
return input.get_initial_value( self.trans, context )
elif connections is None or prefixed_name in input_connections_by_name:
return RuntimeValue()
elif self.trans.workflow_building_mode is workflow_building_modes.USE_HISTORY:
return input.get_initial_value( self.trans, context )

visit_input_values( self.tool.inputs, self.state.inputs, callback )

Expand Down Expand Up @@ -1289,7 +1297,7 @@ def __init__( self, trans, allow_tool_state_corrections=False ):
self.trans = trans
self.allow_tool_state_corrections = allow_tool_state_corrections

def inject( self, step, step_args=None ):
def inject( self, step, step_args=None, steps=None ):
""" Pre-condition: `step` is an ORM object coming from the database, if
supplied `step_args` is the representation of the inputs for that step
supplied via web form.
Expand Down Expand Up @@ -1319,7 +1327,7 @@ def inject( self, step, step_args=None ):

# Any connected input needs to have value DummyDataset (these
# are not persisted so we need to do it every time)
module.add_dummy_datasets( connections=step.input_connections )
module.add_dummy_datasets( connections=step.input_connections, steps=steps )
state, step_errors = module.compute_runtime_state( self.trans, step_args )
step.state = state
if step.type == "subworkflow":
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/tool/tool-form-composite.js.map

Large diffs are not rendered by default.

0 comments on commit 9f75926

Please sign in to comment.