Skip to content

Commit

Permalink
Merge dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
davebx committed Feb 21, 2017
2 parents 5dc9728 + cdb15f6 commit fdf95d3
Show file tree
Hide file tree
Showing 27 changed files with 280 additions and 287 deletions.
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/tool/tool-form-base.js
Expand Up @@ -40,7 +40,7 @@ define( [ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view
var self = this;
this.model.set( options );
this.model.set({
title : '<b>' + options.name + '</b> ' + options.description + ' (Galaxy Version ' + options.version + ')',
title : options.title || '<b>' + options.name + '</b> ' + options.description + ' (Galaxy Version ' + options.version + ')',
operations : !this.model.get( 'hide_operations' ) && this._operations(),
onchange : function() {
self.deferred.reset();
Expand Down
11 changes: 8 additions & 3 deletions client/galaxy/scripts/mvc/tool/tool-form-composite.js
Expand Up @@ -39,12 +39,18 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
_.each( this.model.get( 'steps' ), function( step, i ) {
Galaxy.emit.debug( 'tool-form-composite::initialize()', i + ' : Preparing workflow step.' );
var icon = WorkflowIcons[ step.step_type ];
var title = parseInt( i + 1 ) + ': ' + ( step.step_label || step.step_name );
if ( step.annotation ) {
title += ' - ' + step.annotation;
}
if ( step.step_version ) {
title += ' (Galaxy Version ' + step.step_version + ')';
}
step = Utils.merge( {
index : i,
name : step.name,
title : _.escape( title ),
icon : icon || '',
help : null,
description : step.annotation && ' - ' + step.annotation || step.description,
citations : null,
collapsible : true,
collapsed : i > 0 && !self._isDataStep( step ),
Expand Down Expand Up @@ -300,7 +306,6 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
var is_simple_input = ([ 'data_input', 'data_collection_input' ]).indexOf( step.step_type ) != -1;
_.each( step.inputs, function( input ) { input.flavor = 'module'; input.hide_label = is_simple_input; } );
form = new Form( Utils.merge({
title : '<b>' + step.name + '</b>',
onchange : function() { _.each( self.links[ step.index ], function( link ) { self._refreshStep( link ) } ) },
inputs : step.inputs && step.inputs.length > 0 ? step.inputs : [ { type: 'hidden', name: 'No options available.', ignore: null } ]
}, step ) );
Expand Down
5 changes: 3 additions & 2 deletions client/galaxy/scripts/mvc/tool/tool-form-workflow.js
Expand Up @@ -38,6 +38,7 @@ define( [ 'utils/utils', 'mvc/tool/tool-form-base' ],
var current_state = {
tool_id : options.id,
tool_version : options.version,
type : 'tool',
inputs : $.extend( true, {}, form.data.create() )
}
Galaxy.emit.debug( 'tool-form-workflow::postchange()', 'Sending current state.', current_state );
Expand All @@ -46,8 +47,8 @@ define( [ 'utils/utils', 'mvc/tool/tool-form-base' ],
url : Galaxy.root + 'api/workflows/build_module',
data : current_state,
success : function( data ) {
form.update( data.tool_model );
form.errors( data.tool_model );
form.update( data.config_form );
form.errors( data.config_form );
// This hasn't modified the workflow, just returned
// module information for the tool to update the workflow
// state stored on the client with. User needs to save
Expand Down
86 changes: 41 additions & 45 deletions client/galaxy/scripts/mvc/workflow/workflow-view.js
Expand Up @@ -670,54 +670,50 @@ define([
content.datatypes = this.datatypes;
form = new ToolForm.View( content );
} else {
if ( content.inputs && content.inputs.length > 0 ) {
content.inputs.unshift({
type : 'text',
name : '__label',
label : 'Label',
value : node.label,
help : 'Add a step label.',
onchange: function( new_label ) {
var duplicate = false;
for ( var i in self.workflow.nodes ) {
var n = self.workflow.nodes[ i ];
if ( n.label && n.label == new_label && n.id != node.id ) {
duplicate = true;
break;
}
content.inputs.unshift({
type : 'text',
name : '__label',
label : 'Label',
value : node.label,
help : 'Add a step label.',
onchange: function( new_label ) {
var duplicate = false;
for ( var i in self.workflow.nodes ) {
var n = self.workflow.nodes[ i ];
if ( n.label && n.label == new_label && n.id != node.id ) {
duplicate = true;
break;
}
var input_id = form.data.match( '__label' );
var input_element = form.element_list[ input_id ];
input_element.model.set( 'error_text', duplicate && 'Duplicate label. Please fix this before saving the workflow.' );
form.trigger( 'change' );
}
var input_id = form.data.match( '__label' );
var input_element = form.element_list[ input_id ];
input_element.model.set( 'error_text', duplicate && 'Duplicate label. Please fix this before saving the workflow.' );
form.trigger( 'change' );
}
});
content.inputs.push({
type : 'text',
name : '__annotation',
label : 'Annotation',
value : node.annotation,
area : true,
help : 'Add an annotation or notes to this step. Annotations are available when a workflow is viewed.'
});
content.onchange = function() {
Utils.request({
type : 'POST',
url : Galaxy.root + 'api/workflows/build_module',
data : {
id : node.id,
type : node.type,
content_id : node.content_id,
inputs : form.data.create()
},
success : function( data ) {
node.update_field_data( data );
}
});
content.inputs.push({
type : 'text',
name : '__annotation',
label : 'Annotation',
value : node.annotation,
area : true,
help : 'Add an annotation or notes to this step. Annotations are available when a workflow is viewed.'
});
content.onchange = function() {
Utils.request({
type : 'POST',
url : Galaxy.root + 'api/workflows/build_module',
data : {
id : node.id,
type : node.type,
inputs : form.data.create()
},
success : function( data ) {
node.update_field_data( data );
}
});
};
} else {
content.message = 'No inputs available for this module.';
content.message_status = 'info';
}
};
form = new Form( content );
}
$el.append( form.$el );
Expand Down
7 changes: 5 additions & 2 deletions config/galaxy.ini.sample
Expand Up @@ -1317,8 +1317,11 @@ use_interactive = True

# -- Galaxy Application Internal Message Queue

# Galaxy uses AMQP internally TODO more documentation on what for.
# For examples, see http://ask.github.io/kombu/userguide/connections.html
# Galaxy uses AMQP internally for communicating between processes. For
# example, when reloading the toolbox or locking job execution, the process
# that handled that particular request will tell all others to also reload,
# lock jobs, etc.
# For connection examples, see http://docs.celeryproject.org/projects/kombu/en/latest/userguide/connections.html
#
# Without specifying anything here, galaxy will first attempt to use your
# specified database_connection above. If that's not specified either, Galaxy
Expand Down
19 changes: 8 additions & 11 deletions lib/galaxy/managers/workflows.py
Expand Up @@ -370,10 +370,6 @@ def _workflow_to_dict_run( self, trans, stored ):
step_models = []
for i, step in enumerate( workflow.steps ):
step_model = None

def step_title(step, default_name):
return "%d: %s" % (step.order_index + 1, step.label or default_name)

if step.type == 'tool':
incoming = {}
tool = trans.app.toolbox.get_tool( step.tool_id )
Expand All @@ -385,14 +381,15 @@ def step_title(step, default_name):
'output_name' : pja.output_name,
'action_arguments' : pja.action_arguments
} for pja in step.post_job_actions ]
step_model["name"] = step_title(step, step_model.get("name"))
else:
inputs = step.module.get_runtime_inputs( connections=step.output_connections )
step_model = {
'name' : step_title(step, step.module.name),
'inputs' : [ input.to_dict( trans ) for input in inputs.itervalues() ]
}
step_model[ 'step_type' ] = step.type
step_model[ 'step_label' ] = step.label
step_model[ 'step_name' ] = step.module.get_name()
step_model[ 'step_version' ] = step.module.get_version()
step_model[ 'step_index' ] = step.order_index
step_model[ 'output_connections' ] = [ {
'input_step_index' : step_order_indices.get( oc.input_step_id ),
Expand Down Expand Up @@ -452,6 +449,7 @@ def _workflow_to_dict_editor(self, trans, stored):
step_dict = {
'id': step.order_index,
'type': module.type,
'label': module.label,
'content_id': module.get_content_id(),
'name': module.get_name(),
'tool_state': module.get_state(),
Expand All @@ -463,7 +461,6 @@ def _workflow_to_dict_editor(self, trans, stored):
'annotation': annotation_str,
'post_job_actions': {},
'uuid': str(step.uuid) if step.uuid else None,
'label': step.label or None,
'workflow_outputs': []
}
# Connections
Expand Down Expand Up @@ -615,7 +612,7 @@ def _workflow_to_dict_export( self, trans, stored=None, workflow=None ):

# Data inputs
input_dicts = []
step_state = module.state.inputs
step_state = module.state.inputs or {}
if "name" in step_state:
name = step_state.get( "name" )
input_dicts.append( { "name": name, "description": annotation_str } )
Expand Down Expand Up @@ -711,9 +708,9 @@ def _workflow_to_dict_instance(self, stored, legacy=True):
inputs = {}
for step in workflow.input_steps:
step_type = step.type
step_name = step.name
if step_name:
label = step_name
step_label = step.label or step.tool_inputs.get( 'name' )
if step_label:
label = step_label
elif step_type == "data_input":
label = "Input Dataset"
elif step_type == "data_collection_input":
Expand Down
9 changes: 0 additions & 9 deletions lib/galaxy/model/__init__.py
Expand Up @@ -34,7 +34,6 @@
from galaxy.util.bunch import Bunch
from galaxy.util.dictifiable import Dictifiable
from galaxy.util.hash_util import new_secure_hash
from galaxy.util.json import safe_loads
from galaxy.util.multi_byte import is_multi_byte
from galaxy.util.sanitize_html import sanitize_html
from galaxy.web.form_builder import (AddressField, CheckboxField, HistoryField,
Expand Down Expand Up @@ -3759,14 +3758,6 @@ def content_id( self ):
content_id = None
return content_id

@property
def name( self ):
state = self.tool_inputs
if state:
state = safe_loads( state )
identifier = state.get( 'name' )
return safe_loads( identifier )

@property
def input_connections_by_name(self):
if self._input_connections_by_name is None:
Expand Down
81 changes: 3 additions & 78 deletions lib/galaxy/tools/__init__.py
Expand Up @@ -46,6 +46,7 @@
params_from_strings,
params_to_incoming,
params_to_strings,
populate_state,
visit_input_values
)
from galaxy.tools.parameters import output_collect
Expand Down Expand Up @@ -1245,7 +1246,7 @@ def handle_input( self, trans, incoming, history=None ):
else:
# Update state for all inputs on the current page taking new
# values from `incoming`.
self.populate_state( request_context, self.inputs, expanded_incoming, params, errors )
populate_state( request_context, self.inputs, expanded_incoming, params, errors )

# If the tool provides a `validate_input` hook, call it.
validate_input = self.get_hook( 'validate_input' )
Expand Down Expand Up @@ -1801,7 +1802,7 @@ def to_json( self, trans, kwd={}, job=None, workflow_building_mode=False ):
# create tool state
state_inputs = {}
state_errors = {}
self.populate_state( request_context, self.inputs, params.__dict__, state_inputs, state_errors )
populate_state( request_context, self.inputs, params.__dict__, state_inputs, state_errors )

# create tool model
tool_model = self.to_dict( request_context )
Expand Down Expand Up @@ -1881,82 +1882,6 @@ def populate_model( self, request_context, inputs, state_inputs, group_inputs, o
pass
group_inputs[ input_index ] = tool_dict

# populates state from incoming parameters
def populate_state( self, request_context, inputs, incoming, state, errors={}, prefix='', context=None ):
context = ExpressionContext( state, context )
for input in inputs.values():
state[ input.name ] = input.get_initial_value( request_context, context )
key = prefix + input.name
group_state = state[ input.name ]
group_prefix = '%s|' % ( key )
if input.type == 'repeat':
rep_index = 0
del group_state[:]
while True:
rep_prefix = '%s_%d' % ( key, rep_index )
if not any( incoming_key.startswith( rep_prefix ) for incoming_key in incoming.keys() ) and rep_index >= input.min:
break
if rep_index < input.max:
new_state = { '__index__' : rep_index }
group_state.append( new_state )
self.populate_state( request_context, input.inputs, incoming, new_state, errors, prefix=rep_prefix + '|', context=context )
rep_index += 1
elif input.type == 'conditional':
if input.value_ref and not input.value_ref_in_group:
test_param_key = prefix + input.test_param.name
else:
test_param_key = group_prefix + input.test_param.name
test_param_value = incoming.get( test_param_key, group_state.get( input.test_param.name ) )
value, error = check_param( request_context, input.test_param, test_param_value, context )
if error:
errors[ test_param_key ] = error
else:
try:
current_case = input.get_current_case( value )
group_state = state[ input.name ] = {}
self.populate_state( request_context, input.cases[ current_case ].inputs, incoming, group_state, errors, prefix=group_prefix, context=context )
group_state[ '__current_case__' ] = current_case
except Exception:
errors[ test_param_key ] = 'The selected case is unavailable/invalid.'
pass
group_state[ input.test_param.name ] = value
elif input.type == 'section':
self.populate_state( request_context, input.inputs, incoming, group_state, errors, prefix=group_prefix, context=context )
elif input.type == 'upload_dataset':
d_type = input.get_datatype( request_context, context=context )
writable_files = d_type.writable_files
while len( group_state ) > len( writable_files ):
del group_state[ -1 ]
while len( writable_files ) > len( group_state ):
new_state = { '__index__' : len( group_state ) }
for upload_item in input.inputs.values():
new_state[ upload_item.name ] = upload_item.get_initial_value( request_context, context )
group_state.append( new_state )
for i, rep_state in enumerate( group_state ):
rep_index = rep_state[ '__index__' ]
rep_prefix = '%s_%d|' % ( key, rep_index )
self.populate_state( request_context, input.inputs, incoming, rep_state, errors, prefix=rep_prefix, context=context )
else:
param_value = self._get_incoming_value( incoming, key, state.get( input.name ) )
value, error = check_param( request_context, input, param_value, context )
if error:
errors[ key ] = error
state[ input.name ] = value

def _get_incoming_value( self, incoming, key, default ):
"""
Fetch value from incoming dict directly or check special nginx upload
created variants of this key.
"""
if '__' + key + '__is_composite' in incoming:
composite_keys = incoming[ '__' + key + '__keys' ].split()
value = dict()
for composite_key in composite_keys:
value[ composite_key ] = incoming[ key + '_' + composite_key ]
return value
else:
return incoming.get( key, default )

def _get_job_remap( self, job):
if job:
if job.state == job.states.ERROR:
Expand Down

0 comments on commit fdf95d3

Please sign in to comment.