commit/galaxy-central: jmchilton: Minor style and refactoring touch up to new workflow/run.py.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/21c6fe1aec03/ Changeset: 21c6fe1aec03 User: jmchilton Date: 2014-02-07 23:59:37 Summary: Minor style and refactoring touch up to new workflow/run.py. Reduces cyclomatic complexity and makes downstream diffs with dataset collection work less dramatic. Affected #: 2 files diff -r 749db2ae03b4ff4c83053322ef291af3b9173325 -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -152,6 +152,7 @@ .add_text( "name", "Name", value=self.state['name'] ) return self.trans.fill_template( "workflow/editor_generic_form.mako", module=self, form=form ) + def get_state( self, secure=True ): return to_json_string( self.state ) @@ -168,11 +169,11 @@ return state def encode_runtime_state( self, trans, state ): - fake_tool = Bunch( inputs = self.get_runtime_inputs() ) + fake_tool = Bunch( inputs=self.get_runtime_inputs() ) return state.encode( fake_tool, trans.app ) def decode_runtime_state( self, trans, string ): - fake_tool = Bunch( inputs = self.get_runtime_inputs() ) + fake_tool = Bunch( inputs=self.get_runtime_inputs() ) state = galaxy.tools.DefaultToolState() state.decode( string, fake_tool, trans.app ) return state @@ -221,7 +222,7 @@ module.state = galaxy.tools.DefaultToolState() if module.tool is not None: if d.get('tool_version', 'Unspecified') != module.get_tool_version(): - module.version_changes.append("%s: using version '%s' instead of version '%s' indicated in this workflow." % (tool_id, d.get('tool_version', 'Unspecified'), module.get_tool_version()) ) + module.version_changes.append( "%s: using version '%s' instead of version '%s' indicated in this workflow." % ( tool_id, d.get( 'tool_version', 'Unspecified' ), module.get_tool_version() ) ) module.state.decode( d[ "tool_state" ], module.tool, module.trans.app, secure=secure ) module.errors = d.get( "tool_errors", None ) module.post_job_actions = d.get( "post_job_actions", {} ) @@ -329,7 +330,7 @@ data_inputs = None for name, tool_output in self.tool.outputs.iteritems(): if tool_output.format_source != None: - formats = [ 'input' ] # default to special name "input" which remove restrictions on connections + formats = [ 'input' ] # default to special name "input" which remove restrictions on connections if data_inputs == None: data_inputs = self.get_data_inputs() # find the input parameter referenced by format_source diff -r 749db2ae03b4ff4c83053322ef291af3b9173325 -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 lib/galaxy/workflow/run.py --- a/lib/galaxy/workflow/run.py +++ b/lib/galaxy/workflow/run.py @@ -64,7 +64,6 @@ def _execute_tool_step( self, step ): trans = self.trans outputs = self.outputs - replacement_dict = self.replacement_dict tool = trans.app.toolbox.get_tool( step.tool_id ) @@ -72,12 +71,7 @@ def callback( input, value, prefixed_name, prefixed_label ): replacement = None if isinstance( input, DataToolParameter ): - if prefixed_name in step.input_connections_by_name: - conn = step.input_connections_by_name[ prefixed_name ] - if input.multiple: - replacement = [outputs[ c.output_step.id ][ c.output_name ] for c in conn] - else: - replacement = outputs[ conn[0].output_step.id ][ conn[0].output_name ] + replacement = self._replacement_for_input( input, prefixed_name, step ) return replacement try: # Replace DummyDatasets with historydatasetassociations @@ -85,17 +79,10 @@ except KeyError, k: raise exceptions.MessageException( "Error due to input mapping of '%s' in '%s'. A common cause of this is conditional outputs that cannot be determined until runtime, please review your workflow." % (tool.name, k.message)) # Execute it - job, out_data = tool.execute( trans, step.state.inputs, history=self.target_history) + job, out_data = tool.execute( trans, step.state.inputs, history=self.target_history ) outputs[ step.id ] = out_data - # Create new PJA associations with the created job, to be run on completion. - # PJA Parameter Replacement (only applies to immediate actions-- rename specifically, for now) - # Pass along replacement dict with the execution of the PJA so we don't have to modify the object. - for pja in step.post_job_actions: - if pja.action_type in ActionBox.immediate_actions: - ActionBox.execute( trans.app, trans.sa_session, pja, job, replacement_dict ) - else: - job.add_post_job_action(pja) + self._handle_post_job_actions( step, job ) return job def _execute_input_step( self, step ): @@ -110,10 +97,35 @@ if self.copy_inputs_to_history: for input_dataset_hda in out_data.values(): new_hda = input_dataset_hda.copy( copy_children=True ) - self.target_history.add_dataset(new_hda) - outputs[ step.id ]['input_ds_copy'] = new_hda + self.target_history.add_dataset( new_hda ) + outputs[ step.id ][ 'input_ds_copy' ] = new_hda if self.ds_map: - outputs[step.id]['output'] = self.ds_map[ str( step.id ) ][ 'hda' ] + outputs[ step.id ][ 'output' ] = self.ds_map[ str( step.id ) ][ 'hda' ] + return job + def _handle_post_job_actions( self, step, job ): + # Create new PJA associations with the created job, to be run on completion. + # PJA Parameter Replacement (only applies to immediate actions-- rename specifically, for now) + # Pass along replacement dict with the execution of the PJA so we don't have to modify the object. + for pja in step.post_job_actions: + if pja.action_type in ActionBox.immediate_actions: + ActionBox.execute( self.trans.app, self.trans.sa_session, pja, job, self.replacement_dict ) + else: + job.add_post_job_action( pja ) + + def _replacement_for_input( self, input, prefixed_name, step ): + """ For given workflow 'step' that has had input_connections_by_name + populated fetch the actual runtime input for the given tool 'input'. + """ + replacement = None + if prefixed_name in step.input_connections_by_name: + outputs = self.outputs + connection = step.input_connections_by_name[ prefixed_name ] + if input.multiple: + replacement = [ outputs[ c.output_step.id ][ c.output_name ] for c in connection ] + else: + replacement = outputs[ connection[ 0 ].output_step.id ][ connection[ 0 ].output_name ] + return replacement + __all__ = [ invoke ] Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org