Merge pull request #2390 from guerler/revise_tool_framework_000

Add a new workflow building mode variation which does access the history
This commit is contained in:
John Chilton
2016-05-23 09:16:14 -04:00
4 changed files with 16 additions and 13 deletions
+2 -2
View File
@@ -1578,7 +1578,7 @@ class Tool( object, Dictifiable ):
return tool_dict
def to_json( self, trans, kwd={}, job=None, workflow_mode=False ):
def to_json( self, trans, kwd={}, job=None, workflow_building_mode=False ):
"""
Recursively creates a tool dictionary containing repeats, dynamic options and updated states.
"""
@@ -1595,7 +1595,7 @@ class Tool( object, Dictifiable ):
raise exceptions.MessageException( '[history_id=%s] Failed to retrieve history. %s.' % ( history_id, str( e ) ) )
# build request context
request_context = WorkRequestContext( app=trans.app, user=trans.user, history=history, workflow_building_mode=workflow_mode )
request_context = WorkRequestContext( app=trans.app, user=trans.user, history=history, workflow_building_mode=workflow_building_mode )
# load job parameters into incoming
tool_message = ''
+12 -9
View File
@@ -25,9 +25,12 @@ from .dataset_matcher import DatasetCollectionMatcher
from galaxy.web import url_for
from galaxy.util.dictifiable import Dictifiable
import galaxy.model
from galaxy.util.bunch import Bunch
log = logging.getLogger(__name__)
workflow_building_modes = Bunch( DISABLED=False, ENABLED=True, USE_HISTORY=1 )
WORKFLOW_PARAMETER_REGULAR_EXPRESSION = re.compile( '''\$\{.+?\}''' )
@@ -266,7 +269,7 @@ class TextToolParameter( ToolParameter ):
def validate( self, value, trans=None ):
search = self.type == "text"
if not ( trans and trans.workflow_building_mode and contains_workflow_parameter(value, search=search) ):
if not ( trans and trans.workflow_building_mode is workflow_building_modes.ENABLED and contains_workflow_parameter(value, search=search) ):
return super( TextToolParameter, self ).validate( value, trans )
def get_initial_value( self, trans, other_values ):
@@ -333,11 +336,11 @@ class IntegerToolParameter( TextToolParameter ):
try:
return int( value )
except:
if contains_workflow_parameter( value ) and trans.workflow_building_mode:
if contains_workflow_parameter( value ) and trans.workflow_building_mode is workflow_building_modes.ENABLED:
return value
if not value and self.optional:
return ""
if trans.workflow_building_mode:
if trans.workflow_building_mode is workflow_building_modes.ENABLED:
raise ValueError( "An integer or workflow parameter e.g. ${name} is required" )
else:
raise ValueError( "An integer is required" )
@@ -413,11 +416,11 @@ class FloatToolParameter( TextToolParameter ):
try:
return float( value )
except:
if contains_workflow_parameter( value ) and trans.workflow_building_mode:
if contains_workflow_parameter( value ) and trans.workflow_building_mode is workflow_building_modes.ENABLED:
return value
if not value and self.optional:
return ""
if trans and trans.workflow_building_mode:
if trans and trans.workflow_building_mode is workflow_building_modes.ENABLED:
raise ValueError( "A real number or workflow parameter e.g. ${name} is required" )
else:
raise ValueError( "A real number is required" )
@@ -1860,7 +1863,7 @@ class DataToolParameter( BaseDataToolParameter ):
return ''
def from_json( self, value, trans, other_values={} ):
if trans.workflow_building_mode:
if trans.workflow_building_mode is workflow_building_modes.ENABLED:
return None
if not value and not self.optional:
raise ValueError( "History does not include a dataset of the required format / build" )
@@ -2043,7 +2046,7 @@ class DataToolParameter( BaseDataToolParameter ):
# return dictionary without options if context is unavailable
history = trans.history
if history is None or trans.workflow_building_mode:
if history is None or trans.workflow_building_mode is workflow_building_modes.ENABLED:
return d
# prepare dataset/collection matching
@@ -2144,7 +2147,7 @@ class DataCollectionToolParameter( BaseDataToolParameter ):
return field
def from_json( self, value, trans, other_values={} ):
if trans.workflow_building_mode:
if trans.workflow_building_mode is workflow_building_modes.ENABLED:
return None
if not value and not self.optional:
raise ValueError( "History does not include a dataset collection of the correct type or containing the correct types of datasets" )
@@ -2205,7 +2208,7 @@ class DataCollectionToolParameter( BaseDataToolParameter ):
# return dictionary without options if context is unavailable
history = trans.history
if history is None or trans.workflow_building_mode or other_values is None:
if history is None or trans.workflow_building_mode is workflow_building_modes.ENABLED or other_values is None:
return d
# prepare dataset/collection matching
+1 -1
View File
@@ -334,7 +334,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
} )
# create tool model and default tool state (if missing)
tool_model = module.tool.to_json( trans, tool_inputs, workflow_mode=True )
tool_model = module.tool.to_json( trans, tool_inputs, workflow_building_mode=True )
module.update_state( tool_model[ 'state_inputs' ] )
return {
'tool_model' : tool_model,
@@ -4,7 +4,7 @@
from galaxy.tools.parameters import params_to_incoming
incoming = {}
params_to_incoming( incoming, tool.inputs, module.state.inputs, trans.app )
self.form_config = tool.to_json(trans, incoming, workflow_mode=True)
self.form_config = tool.to_json(trans, incoming, workflow_building_mode=True)
self.form_config.update({
'id' : tool.id,
'job_id' : trans.security.encode_id( job.id ) if job else None,