commit/galaxy-central: 6 new changesets
6 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/fc0769d68f40/ Changeset: fc0769d68f40 User: jmchilton Date: 2014-08-14 04:52:59 Summary: PEP-8 fixes and comments for workflow_util.py. Affected #: 1 file diff -r 08e25f0ffc06543bd76efbe7bca8a329bb1858cb -r fc0769d68f4071701bca612823587b1ccea1cbef lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -1,3 +1,6 @@ +""" Tool shed helper methods for dealing with workflows - only two methods are +utilized outside of this modules - generate_workflow_image and import_workflow. +""" import logging import os @@ -6,7 +9,7 @@ import galaxy.webapps.galaxy.controllers.workflow from galaxy.util import json from galaxy.util.sanitize_html import sanitize_html -from galaxy.workflow.render import WorkflowCanvas, MARGIN, LINE_SPACING +from galaxy.workflow.render import WorkflowCanvas from galaxy.workflow.modules import InputDataModule from galaxy.workflow.modules import ToolModule from galaxy.workflow.modules import WorkflowModuleFactory @@ -106,6 +109,7 @@ def get_data_inputs( self ): data_inputs = [] + def callback( input, value, prefixed_name, prefixed_label ): if isinstance( input, galaxy.tools.parameters.DataToolParameter ): data_inputs.append( dict( name=prefixed_name, @@ -125,16 +129,16 @@ if self.tool: data_inputs = None for name, tool_output in self.tool.outputs.iteritems(): - if tool_output.format_source != None: + if tool_output.format_source is not None: # Default to special name "input" which remove restrictions on connections formats = [ 'input' ] - if data_inputs == None: + if data_inputs is None: data_inputs = self.get_data_inputs() # Find the input parameter referenced by format_source for di in data_inputs: # Input names come prefixed with conditional and repeat names separated by '|', # so remove prefixes when comparing with format_source. - if di[ 'name' ] != None and di[ 'name' ].split( '|' )[ -1 ] == tool_output.format_source: + if di[ 'name' ] is not None and di[ 'name' ].split( '|' )[ -1 ] == tool_output.format_source: formats = di[ 'extensions' ] else: formats = [ tool_output.format ] @@ -170,6 +174,7 @@ module_factory = RepoWorkflowModuleFactory( dict( data_input=RepoInputDataModule, tool=RepoToolModule ) ) + def generate_workflow_image( trans, workflow_name, repository_metadata_id=None, repository_id=None ): """ Return an svg image representation of a workflow dictionary created when the workflow was exported. This method is called @@ -225,6 +230,7 @@ trans.response.set_content_type( "image/svg+xml" ) return canvas.standalone_xml() + def get_workflow_data_inputs( step, module ): if module.type == 'tool': if module.tool: @@ -240,6 +246,7 @@ return data_inputs return module.get_data_inputs() + def get_workflow_data_outputs( step, module, steps ): if module.type == 'tool': if module.tool: @@ -264,6 +271,7 @@ return data_outputs return module.get_data_outputs() + def get_workflow_from_dict( trans, workflow_dict, tools_metadata, repository_id, changeset_revision ): """ Return an in-memory Workflow object from the dictionary object created when it was exported. This method is called from @@ -334,6 +342,7 @@ # Return the in-memory Workflow object for display or later persistence to the Galaxy database. return workflow, missing_tool_tups + def get_workflow_module_name( module, missing_tool_tups ): module_name = module.get_name() if module.type == 'tool' and module_name == 'unavailable': @@ -344,6 +353,7 @@ break return module_name + def import_workflow( trans, repository, workflow_name ): """Import a workflow contained in an installed tool shed repository into Galaxy (this method is called only from Galaxy).""" status = 'done' @@ -402,14 +412,15 @@ status = 'error' return workflow, status, message -def save_workflow( trans, workflow, workflow_dict = None): + +def save_workflow( trans, workflow, workflow_dict=None): """Use the received in-memory Workflow object for saving to the Galaxy database.""" stored = trans.model.StoredWorkflow() stored.name = workflow.name workflow.stored_workflow = stored stored.latest_workflow = workflow stored.user = trans.user - if workflow_dict and workflow_dict.get('annotation',''): + if workflow_dict and workflow_dict.get('annotation', ''): annotation = sanitize_html( workflow_dict['annotation'], 'utf-8', 'text/html' ) new_annotation = trans.model.StoredWorkflowAnnotationAssociation() new_annotation.annotation = annotation https://bitbucket.org/galaxy/galaxy-central/commits/c627f39b9b99/ Changeset: c627f39b9b99 User: jmchilton Date: 2014-08-14 04:52:59 Summary: Remove unused method. Affected #: 1 file diff -r fc0769d68f4071701bca612823587b1ccea1cbef -r c627f39b9b997b526a1e4adfca4ec6c10587c8e4 lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -156,11 +156,6 @@ def __init__( self, module_types ): self.module_types = module_types - def new( self, trans, type, tools_metadata=None, tool_id=None ): - """Return module for type and (optional) tool_id initialized with new / default state.""" - assert type in self.module_types - return self.module_types[ type ].new( trans, tool_id ) - def from_dict( self, trans, repository_id, changeset_revision, step_dict, **kwd ): """Return module initialized from the data in dictionary `step_dict`.""" type = step_dict[ 'type' ] https://bitbucket.org/galaxy/galaxy-central/commits/3874a0ab5e3d/ Changeset: 3874a0ab5e3d User: jmchilton Date: 2014-08-14 04:52:59 Summary: Rearrange module arguments to bring ts workflow modules more inline with Galaxy. Will enable remove tool shed specific input module in a subsequent changeset. Affected #: 1 file diff -r c627f39b9b997b526a1e4adfca4ec6c10587c8e4 -r 3874a0ab5e3d71f34f29cc9bd2883c3b9165dec5 lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -35,14 +35,14 @@ return module @classmethod - def from_dict( Class, trans, repository_id, changeset_revision, step_dict, tools_metadata=None, secure=True ): + def from_dict( Class, trans, step_dict, repository_id, changeset_revision, tools_metadata=None, secure=True ): module = Class( trans ) state = json.from_json_string( step_dict[ "tool_state" ] ) module.state = dict( name=state.get( "name", "Input Dataset" ) ) return module @classmethod - def from_workflow_step( Class, trans, repository_id, changeset_revision, tools_metadata, step ): + def from_workflow_step( Class, trans, step, repository_id, changeset_revision, tools_metadata ): module = Class( trans ) module.state = dict( name="Input Dataset" ) if step.tool_inputs and "name" in step.tool_inputs: @@ -87,7 +87,7 @@ return module @classmethod - def from_dict( Class, trans, repository_id, changeset_revision, step_dict, tools_metadata, secure=True ): + def from_dict( Class, trans, step_dict, repository_id, changeset_revision, tools_metadata, secure=True ): tool_id = step_dict[ 'tool_id' ] module = Class( trans, repository_id, changeset_revision, tools_metadata, tool_id ) module.state = galaxy.tools.DefaultToolState() @@ -97,7 +97,7 @@ return module @classmethod - def from_workflow_step( Class, trans, repository_id, changeset_revision, tools_metadata, step ): + def from_workflow_step( Class, trans, step, repository_id, changeset_revision, tools_metadata ): module = Class( trans, repository_id, changeset_revision, tools_metadata, step.tool_id ) module.state = galaxy.tools.DefaultToolState() if module.tool: @@ -160,12 +160,12 @@ """Return module initialized from the data in dictionary `step_dict`.""" type = step_dict[ 'type' ] assert type in self.module_types - return self.module_types[ type ].from_dict( trans, repository_id, changeset_revision, step_dict, **kwd ) + return self.module_types[ type ].from_dict( trans, step_dict, repository_id=repository_id, changeset_revision=changeset_revision, **kwd ) def from_workflow_step( self, trans, repository_id, changeset_revision, tools_metadata, step ): """Return module initialized from the WorkflowStep object `step`.""" type = step.type - return self.module_types[ type ].from_workflow_step( trans, repository_id, changeset_revision, tools_metadata, step ) + return self.module_types[ type ].from_workflow_step( trans, step, repository_id=repository_id, changeset_revision=changeset_revision, tools_metadata=tools_metadata ) module_factory = RepoWorkflowModuleFactory( dict( data_input=RepoInputDataModule, tool=RepoToolModule ) ) https://bitbucket.org/galaxy/galaxy-central/commits/f8b0a85a04c0/ Changeset: f8b0a85a04c0 User: jmchilton Date: 2014-08-14 04:52:59 Summary: Remove unused methods. Affected #: 1 file diff -r 3874a0ab5e3d71f34f29cc9bd2883c3b9165dec5 -r f8b0a85a04c0e4d8d84aebf2cd52adbef5fa6e29 lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -29,12 +29,6 @@ name = "Input dataset" @classmethod - def new( Class, trans, tools_metadata=None, tool_id=None ): - module = Class( trans ) - module.state = dict( name="Input Dataset" ) - return module - - @classmethod def from_dict( Class, trans, step_dict, repository_id, changeset_revision, tools_metadata=None, secure=True ): module = Class( trans ) state = json.from_json_string( step_dict[ "tool_state" ] ) @@ -81,12 +75,6 @@ self.state = None @classmethod - def new( Class, trans, repository_id, changeset_revision, tools_metadata, tool_id=None ): - module = Class( trans, repository_id, changeset_revision, tools_metadata, tool_id ) - module.state = module.tool.new_state( trans, all_pages=True ) - return module - - @classmethod def from_dict( Class, trans, step_dict, repository_id, changeset_revision, tools_metadata, secure=True ): tool_id = step_dict[ 'tool_id' ] module = Class( trans, repository_id, changeset_revision, tools_metadata, tool_id ) https://bitbucket.org/galaxy/galaxy-central/commits/a03e7b90d953/ Changeset: a03e7b90d953 User: jmchilton Date: 2014-08-14 04:52:59 Summary: Rework tool shed's workflow module factory so only tool module needs to be different. Fixes dataset collection inputs in the tool shed. Furthermore, this will allow all all future non-tool modules to be the same between Galaxy and the Tool Shed as well. May seem hacky - but it is removing duplication and it makes some intuitive sense that only the tool module would need to function differently between Galaxy and the tool shed anyway - input parameters, if statements, stop and review steps, etc... will all likely not depend on tool shed artifacts. Affected #: 2 files diff -r f8b0a85a04c0e4d8d84aebf2cd52adbef5fa6e29 -r a03e7b90d9534ae7a495f76bc320fb81d764d2bb lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -536,4 +536,5 @@ type = step.type return self.module_types[type].from_workflow_step( trans, step ) -module_factory = WorkflowModuleFactory( dict( data_input=InputDataModule, data_collection_input=InputDataCollectionModule, tool=ToolModule ) ) +module_types = dict( data_input=InputDataModule, data_collection_input=InputDataCollectionModule, tool=ToolModule ) +module_factory = WorkflowModuleFactory( module_types ) diff -r f8b0a85a04c0e4d8d84aebf2cd52adbef5fa6e29 -r a03e7b90d9534ae7a495f76bc320fb81d764d2bb lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -10,7 +10,7 @@ from galaxy.util import json from galaxy.util.sanitize_html import sanitize_html from galaxy.workflow.render import WorkflowCanvas -from galaxy.workflow.modules import InputDataModule +from galaxy.workflow.modules import module_types from galaxy.workflow.modules import ToolModule from galaxy.workflow.modules import WorkflowModuleFactory @@ -23,27 +23,6 @@ log = logging.getLogger( __name__ ) -class RepoInputDataModule( InputDataModule ): - - type = "data_input" - name = "Input dataset" - - @classmethod - def from_dict( Class, trans, step_dict, repository_id, changeset_revision, tools_metadata=None, secure=True ): - module = Class( trans ) - state = json.from_json_string( step_dict[ "tool_state" ] ) - module.state = dict( name=state.get( "name", "Input Dataset" ) ) - return module - - @classmethod - def from_workflow_step( Class, trans, step, repository_id, changeset_revision, tools_metadata ): - module = Class( trans ) - module.state = dict( name="Input Dataset" ) - if step.tool_inputs and "name" in step.tool_inputs: - module.state[ 'name' ] = step.tool_inputs[ 'name' ] - return module - - class RepoToolModule( ToolModule ): type = "tool" @@ -144,18 +123,30 @@ def __init__( self, module_types ): self.module_types = module_types - def from_dict( self, trans, repository_id, changeset_revision, step_dict, **kwd ): + def from_dict( self, trans, repository_id, changeset_revision, step_dict, tools_metadata, **kwd ): """Return module initialized from the data in dictionary `step_dict`.""" type = step_dict[ 'type' ] assert type in self.module_types - return self.module_types[ type ].from_dict( trans, step_dict, repository_id=repository_id, changeset_revision=changeset_revision, **kwd ) + module_method_kwds = dict( **kwd ) + if type == "tool": + module_method_kwds[ 'repository_id' ] = repository_id + module_method_kwds[ 'changeset_revision' ] = changeset_revision + module_method_kwds[ 'tools_metadata' ] = tools_metadata + return self.module_types[ type ].from_dict( trans, step_dict, **module_method_kwds ) def from_workflow_step( self, trans, repository_id, changeset_revision, tools_metadata, step ): """Return module initialized from the WorkflowStep object `step`.""" type = step.type - return self.module_types[ type ].from_workflow_step( trans, step, repository_id=repository_id, changeset_revision=changeset_revision, tools_metadata=tools_metadata ) + module_method_kwds = dict( ) + if type == "tool": + module_method_kwds[ 'repository_id' ] = repository_id + module_method_kwds[ 'changeset_revision' ] = changeset_revision + module_method_kwds[ 'tools_metadata' ] = tools_metadata + return self.module_types[ type ].from_workflow_step( trans, step, **module_method_kwds ) -module_factory = RepoWorkflowModuleFactory( dict( data_input=RepoInputDataModule, tool=RepoToolModule ) ) +tool_shed_module_types = module_types.copy() +tool_shed_module_types[ 'tool' ] = RepoToolModule +module_factory = RepoWorkflowModuleFactory( tool_shed_module_types ) def generate_workflow_image( trans, workflow_name, repository_metadata_id=None, repository_id=None ): https://bitbucket.org/galaxy/galaxy-central/commits/f58d8cf6018a/ Changeset: f58d8cf6018a User: jmchilton Date: 2014-08-14 04:52:59 Summary: Make run_tool_shed.sh executable. Affected #: 1 file 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