Skip to content

Commit

Permalink
Avoid potential inconsistencies between differently stored labels
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Mar 21, 2017
1 parent a5b0e76 commit 3036df3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from galaxy import util
from galaxy import exceptions
from galaxy.model.item_attrs import UsesAnnotations
from galaxy.util.json import safe_loads
from galaxy.workflow import modules
from .base import decode_id

Expand Down Expand Up @@ -425,7 +426,7 @@ def _workflow_to_dict_editor(self, trans, stored):
if not module:
raise exceptions.MessageException( 'Unrecognized step type: %s' % step.type )
# Load label from state of data input modules, necessary for backward compatibility
self.__set_default_label( module, step.tool_inputs )
self.__set_default_label( step, module, step.tool_inputs )
# Fix any missing parameters
upgrade_message = module.check_and_update_state()
if upgrade_message:
Expand Down Expand Up @@ -833,7 +834,7 @@ def __module_from_dict( self, trans, steps, steps_by_external_id, step_dict, **k
step_dict["subworkflow"] = subworkflow

module = module_factory.from_dict( trans, step_dict, **kwds )
self.__set_default_label( module, step_dict.get( 'tool_state' ) )
self.__set_default_label( step, module, step_dict.get( 'tool_state' ) )
module.save_to_step( step )

annotation = step_dict[ 'annotation' ]
Expand Down Expand Up @@ -923,14 +924,15 @@ def __connect_workflow_steps( self, steps, steps_by_external_id ):

del step.temp_input_connections

def __set_default_label( self, module, state ):
def __set_default_label( self, step, module, state ):
""" Previously data input modules had a `name` attribute to rename individual steps. Here, this value is transferred
to the actual `label` attribute which is available for all module types, unique, and mapped to its own database column.
"""
if not module.label and module.type in [ 'data_input', 'data_collection_input' ] and isinstance( state, dict ):
default_label = state.get( 'name' )
if not module.label and module.type in [ 'data_input', 'data_collection_input' ]:
new_state = safe_loads( state )
default_label = new_state.get( 'name' )
if str( default_label ).lower() not in [ 'input dataset', 'input dataset collection' ]:
module.label = default_label
step.label = module.label = default_label


class MissingToolsException(exceptions.MessageException):
Expand Down

0 comments on commit 3036df3

Please sign in to comment.