3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/94e8e0d8bb6c/ Changeset: 94e8e0d8bb6c User: jmchilton Date: 2014-08-26 16:02:49 Summary: Doc spelling fix in lib/galaxy/workflow/run.py. Affected #: 1 file diff -r 0dc11a77b3cd2003e542c3183539ebdb38b7f65a -r 94e8e0d8bb6c2d9d4a941ba5706a057570f25741 lib/galaxy/workflow/run.py --- a/lib/galaxy/workflow/run.py +++ b/lib/galaxy/workflow/run.py @@ -71,7 +71,7 @@ self.trans.sa_session.add( workflow_invocation ) # Not flushing in here, because web controller may create multiple - # invokations. + # invocations. return self.outputs def _invoke_step( self, step ): https://bitbucket.org/galaxy/galaxy-central/commits/d15f9a1b4782/ Changeset: d15f9a1b4782 User: jmchilton Date: 2014-08-26 16:02:49 Summary: Some very basic unit tests and docs for workflow modules. Just a start - I need to keep going with this and test and document all methods. Affected #: 3 files diff -r 94e8e0d8bb6c2d9d4a941ba5706a057570f25741 -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -71,9 +71,18 @@ ## ---- Configuration time ----------------------------------------------- def get_state( self ): + """ Return a serializable representation of the persistable state of + the step - for tools it DefaultToolState.encode returns a string and + for inputs a json description is dumped out. + """ return None def get_errors( self ): + """ It seems like this is effectively just used as boolean - some places + in the tool shed self.errors is set to boolean, other places 'unavailable', + likewise in Galaxy it stores a list containing a string with an unrecognized + tool id error message. + """ return None def get_data_inputs( self ): @@ -292,6 +301,9 @@ @classmethod def new( Class, trans, tool_id=None ): module = Class( trans, tool_id ) + if module.tool is None: + error_message = "Attempted to create new workflow module for invalid tool_id, no tool with id - %s." % tool_id + raise Exception( error_message ) module.state = module.tool.new_state( trans, all_pages=True ) return module diff -r 94e8e0d8bb6c2d9d4a941ba5706a057570f25741 -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec test/unit/workflows/test_modules.py --- /dev/null +++ b/test/unit/workflows/test_modules.py @@ -0,0 +1,39 @@ +from galaxy import eggs +eggs.require( "mock" ) + + +import mock + +from galaxy.workflow import modules +from .workflow_support import MockTrans + + +def test_input_has_no_errors(): + trans = MockTrans() + input_step_module = modules.module_factory.new( trans, 'data_input' ) + assert not input_step_module.get_errors() + + +def test_valid_new_tool_has_no_errors(): + trans = MockTrans() + mock_tool = mock.Mock() + trans.app.toolbox.tools[ "cat1" ] = mock_tool + tool_module = modules.module_factory.new( trans, 'tool', tool_id="cat1" ) + assert not tool_module.get_errors() + + +def test_missing_tool_has_errors(): + trans = MockTrans() + tool_dict = { "type": "tool", "tool_id": "cat1" } + tool_module = modules.module_factory.from_dict( trans, tool_dict ) + assert tool_module.get_errors() + + +def test_cannot_create_tool_modules_for_missing_tools(): + trans = MockTrans() + exception = False + try: + modules.module_factory.new( trans, 'tool', tool_id="cat1" ) + except Exception: + exception = True + assert exception diff -r 94e8e0d8bb6c2d9d4a941ba5706a057570f25741 -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec test/unit/workflows/workflow_support.py --- a/test/unit/workflows/workflow_support.py +++ b/test/unit/workflows/workflow_support.py @@ -17,3 +17,14 @@ "sqlite:///:memory:", create_tables=True ) + self.toolbox = TestToolbox() + + +class TestToolbox( object ): + + def __init__( self ): + self.tools = {} + + def get_tool( self, tool_id ): + # Real tool box returns None of missing tool also + return self.tools.get( tool_id, None ) https://bitbucket.org/galaxy/galaxy-central/commits/abcccd35b958/ Changeset: abcccd35b958 User: jmchilton Date: 2014-08-26 16:02:49 Summary: Couple simple refactors making it slightly cleaner to create new module types. Also slightly reduces shared logic galaxy.workflow.run. Affected #: 3 files diff -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec -r abcccd35b958bbbf3ad97debe029b8c5452f5d32 lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -24,7 +24,7 @@ from galaxy.web.framework import form from galaxy.web.framework.helpers import grids, time_ago from galaxy.web.framework.helpers import to_unicode -from galaxy.workflow.modules import module_factory +from galaxy.workflow.modules import module_factory, is_tool_module_type from galaxy.workflow.run import invoke from galaxy.workflow.run import WorkflowRunConfig from galaxy.workflow.extract import summarize @@ -836,8 +836,8 @@ steps_by_external_id = {} errors = [] for key, step_dict in data['steps'].iteritems(): - is_input = step_dict[ 'type' ] in [ 'data_input', 'data_collection_input' ] - if not is_input and step_dict['tool_id'] not in trans.app.toolbox.tools_by_id: + is_tool = is_tool_module_type( step_dict[ 'type' ] ) + if is_tool and step_dict['tool_id'] not in trans.app.toolbox.tools_by_id: errors.append("Step %s requires tool '%s'." % (step_dict['id'], step_dict['tool_id'])) if errors: return dict( name=workflow.name, diff -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec -r abcccd35b958bbbf3ad97debe029b8c5452f5d32 lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -548,5 +548,14 @@ type = step.type return self.module_types[type].from_workflow_step( trans, step ) -module_types = dict( data_input=InputDataModule, data_collection_input=InputDataCollectionModule, tool=ToolModule ) + +def is_tool_module_type( module_type ): + return not module_type or module_type == "tool" + + +module_types = dict( + data_input=InputDataModule, + data_collection_input=InputDataCollectionModule, + tool=ToolModule, +) module_factory = WorkflowModuleFactory( module_types ) diff -r d15f9a1b4782e55c5619932c7fabf97052d5a6ec -r abcccd35b958bbbf3ad97debe029b8c5452f5d32 lib/galaxy/workflow/run.py --- a/lib/galaxy/workflow/run.py +++ b/lib/galaxy/workflow/run.py @@ -211,10 +211,9 @@ """ 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 ] + replacement = [ self._replacement_for_connection( c ) for c in connection ] # If replacement is just one dataset collection, replace tool # input with dataset collection - tool framework will extract # datasets properly. @@ -222,9 +221,12 @@ if isinstance( replacement[ 0 ], model.HistoryDatasetCollectionAssociation ): replacement = replacement[ 0 ] else: - replacement = outputs[ connection[ 0 ].output_step.id ][ connection[ 0 ].output_name ] + replacement = self._replacement_for_connection( connection[ 0 ] ) return replacement + def _replacement_for_connection( self, connection ): + return self.outputs[ connection.output_step.id ][ connection.output_name ] + def _populate_state( self ): # Build the state for each step for step in self.workflow.steps: 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.