Merge pull request #2077 from guerler/revise_workflow_run_004

Run workflow form revision
This commit is contained in:
John Chilton
2016-07-07 19:54:35 -04:00
committed by GitHub
9 changed files with 82 additions and 18 deletions
@@ -1,8 +1,9 @@
/** This is the run workflow tool form view. */
define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', 'mvc/form/form-data', 'mvc/tool/tool-form-base' ],
function( Utils, Deferred, Ui, Form, FormData, ToolFormBase ) {
define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', 'mvc/form/form-data', 'mvc/tool/tool-form-base', 'mvc/ui/ui-modal' ],
function( Utils, Deferred, Ui, Form, FormData, ToolFormBase, Modal ) {
var View = Backbone.View.extend({
initialize: function( options ) {
this.modal = parent.Galaxy.modal || new Modal.View();
this.model = options && options.model || new Backbone.Model( options );
this.deferred = new Deferred();
this.setElement( $( '<div/>' ).addClass( 'ui-form-composite' )
@@ -330,7 +331,7 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
var self = this;
var job_def = {
new_history_name : this.history_form.data.create()[ 'new_history|name' ],
wf_parm : this.wp_form ? this.wp_form.data.create() : {},
replacement_params : this.wp_form ? this.wp_form.data.create() : {},
inputs : {}
};
var validated = true;
@@ -371,7 +372,7 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
Galaxy.emit.debug( 'tool-form-composite::submit()', 'Validation complete.', job_def );
Utils.request({
type : 'POST',
url : Galaxy.root + 'api/workflows/' + this.workflow_id + '/invocations',
url : Galaxy.root + 'api/workflows/' + this.model.id + '/run',
data : job_def,
success : function( response ) {
Galaxy.emit.debug( 'tool-form-composite::submit', 'Submission successful.', response );
@@ -393,13 +394,12 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
}
}
} else {
var modal = parent.Galaxy.modal;
modal && modal.show({
self.modal.show({
title : 'Job submission failed',
body : self._templateError( response && response.err_msg || job_def ),
buttons : {
'Close' : function() {
modal.hide();
self.modal.hide();
}
}
});
+67 -2
View File
@@ -15,9 +15,12 @@ from galaxy.web import _future_expose_api as expose_api
from galaxy.web.base.controller import BaseAPIController, url_for, UsesStoredWorkflowMixin
from galaxy.web.base.controller import SharableMixin
from galaxy.workflow.extract import extract_workflow
from galaxy.workflow.run import invoke, queue_invoke
from galaxy.workflow.run import invoke, queue_invoke, WorkflowRunConfig
from galaxy.workflow.run_request import build_workflow_run_config
from galaxy.workflow.modules import module_factory
from galaxy.workflow.modules import module_factory, WorkflowModuleInjector
from galaxy.tools.parameters.basic import workflow_building_modes
from galaxy.tools.parameters.meta import expand_workflow_inputs
log = logging.getLogger(__name__)
@@ -82,6 +85,68 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
style = "instance"
return self.workflow_contents_manager.workflow_to_dict( trans, stored_workflow, style=style )
@expose_api
def run( self, trans, workflow_id, payload, **kwd ):
"""
POST /api/workflows/{encoded_workflow_id}/run
Run a workflow with a dictionary of prefixed_name/value pairs e.g.
payload = { inputs: { step_0: { parameter_0|parameter_1 : value_0, ... }, ... } }
"""
workflow = self.__get_stored_accessible_workflow( trans, workflow_id ).latest_workflow
trans.workflow_building_mode = workflow_building_modes.USE_HISTORY
module_injector = WorkflowModuleInjector( trans )
params, param_keys = expand_workflow_inputs( payload.get( 'inputs', [] ) )
errors = {}
for workflow_args in params:
for step in workflow.steps:
step_args = workflow_args.get( str( step.id ), {} )
step_errors = module_injector.inject( step, step_args )
if step_errors:
errors[ step.id ] = step_errors
if errors:
log.exception( errors )
raise exceptions.MessageException( err_data=errors )
invocations = []
for index, workflow_args in enumerate( params ):
for step in workflow.steps:
step_args = workflow_args.get( str( step.id ), {} )
module_injector.inject( step, step_args )
new_history = None
if 'new_history_name' in payload:
if payload[ 'new_history_name' ]:
nh_name = payload[ 'new_history_name' ]
else:
nh_name = 'History from %s workflow' % workflow.name
if index in param_keys:
ids = param_keys[ index ]
nids = len( ids )
if nids == 1:
nh_name = '%s on %s' % ( nh_name, ids[ 0 ] )
elif nids > 1:
nh_name = '%s on %s and %s' % ( nh_name, ', '.join( ids[ 0:-1 ] ), ids[ -1 ] )
new_history = trans.app.model.History( user=trans.user, name=nh_name )
new_history.copy_tags_from( trans.user, trans.history )
trans.sa_session.add( new_history )
target_history = new_history
elif 'history_id' in payload:
target_history = histories.HistoryManager( trans.app ).get_owned( trans.security.decode_id( payload.get( 'history_id' ), trans.user, current_history=trans.history ) )
else:
target_history = trans.history
run_config = WorkflowRunConfig(
target_history=target_history,
replacement_dict=payload.get( 'replacement_params', {} ),
copy_inputs_to_history=new_history is not None )
invocation = queue_invoke(
trans=trans,
workflow=workflow,
workflow_run_config=run_config,
populate_state=False )
invocations.append({ 'history' : { 'id' : trans.app.security.encode_id( new_history.id ), 'name' : new_history.name } if new_history else None,
'scheduled' : invocation.state == trans.app.model.WorkflowInvocation.states.SCHEDULED })
trans.sa_session.flush()
return invocations
@expose_api
def create(self, trans, payload, **kwd):
"""
+1
View File
@@ -271,6 +271,7 @@ def populate_api_routes( webapp, app ):
webapp.mapper.resource( 'genome', 'genomes', path_prefix='/api' )
webapp.mapper.resource( 'visualization', 'visualizations', path_prefix='/api' )
webapp.mapper.connect( '/api/workflows/build_module', action='build_module', controller="workflows" )
webapp.mapper.connect( '/api/workflows/{workflow_id}/run', action='run', controller="workflows", conditions=dict( method=['POST'] ) )
webapp.mapper.resource( 'workflow', 'workflows', path_prefix='/api' )
webapp.mapper.resource_with_deleted( 'history', 'histories', path_prefix='/api' )
webapp.mapper.connect( '/api/histories/{history_id}/citations', action='citations', controller="histories" )
+2 -4
View File
@@ -1336,11 +1336,9 @@ def populate_module_and_state( trans, workflow, param_map, allow_tool_state_corr
step_errors = module_injector.inject( step, step_args=step_args )
if step.type == 'tool' or step.type is None:
if step_errors:
message = "Workflow cannot be run because of validation errors in some steps: %s" % step_errors
raise exceptions.MessageException( message )
raise exceptions.MessageException( step_errors )
if step.upgrade_messages:
if allow_tool_state_corrections:
log.debug( 'Workflow step "%i" had upgrade messages: %s', step.id, step.upgrade_messages )
else:
message = "Workflow cannot be run because of step upgrade messages: %s" % step.upgrade_messages
raise exceptions.MessageException( message )
raise exceptions.MessageException( step.upgrade_messages )
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"tool-template.js","sources":["../../../src/mvc/tool/tool-template.js"],"names":["define","help","options","$tmpl","$","addClass","append","find","attr","success","response","jobs","length","this","error","njobs","njobs_text","tmpl","i","outputs","hid","name","JSON","stringify","undefined","requirements","requirements_message","req","version"],"mappings":"AACAA,UAAW,WAGX,OACIC,KAAM,SAAUC,GACZ,GAAIC,GAAQC,EAAG,UAAWC,SAAU,gBAAiBC,OAAQJ,EAAQD,KAErE,OADAE,GAAMI,KAAM,KAAMC,KAAM,SAAU,UAC3BL,GAGXM,QAAS,SAASC,GAEd,IAAKA,EAASC,OAASD,EAASC,KAAKC,OACjC,MAAOC,MAAKC,MAAMJ,EAItB,IAAIK,GAAQL,EAASC,KAAKC,OAGtBI,EAAa,EAEbA,GADS,GAATD,EACa,YAEAA,EAAQ,YAIzB,IAAIE,GAAQ,oCACYD,EAAa,kFACrC,KAAK,GAAIE,KAAKR,GAASS,QACnBF,GAAY,qCAAuCP,EAASS,QAAQD,GAAGE,IAAM,KAAOV,EAASS,QAAQD,GAAGG,KAAO,UAMnH,OAJAJ,IAAgB,qQAOpBH,MAAO,SAASJ,GACZ,MAAQ,uMAKQY,KAAKC,UAAUb,EAAUc,OAAW,GACxC,qBAIhBC,aAAc,SAASvB,GACnB,GAAIwB,GAAuB,qBAC3B,KAAK,GAAIR,KAAKhB,GAAQuB,aAAc,CAChC,GAAIE,GAAMzB,EAAQuB,aAAaP,EAC/BQ,IAAwBC,EAAIN,KACxBM,EAAIC,UACJF,GAAwB,aAAeC,EAAIC,QAAU,KAErDV,EAAIhB,EAAQuB,aAAab,OAAS,IAClCc,GAAwB,MAExBR,GAAKhB,EAAQuB,aAAab,OAAS,IACnCc,GAAwB,SAGhC,MAAOA,GAAuB"}
{"version":3,"file":"tool-template.js","sources":["../../../src/mvc/tool/tool-template.js"],"names":["define","error","response","$","append","text","addClass","css","color","height","JSON","stringify","undefined"],"mappings":"AAAAA,UAAW,WACX,OACIC,MAAO,SAAUC,GACb,MAAQC,GAAG,SAAUC,OAAQD,EAAG,QACPE,KAAM,sGACVD,OAAQD,EAAG,eAAgBG,SAAU,eAAgBC,KAAOC,MAAO,QAASC,OAAU,qBAClFJ,KAAMK,KAAKC,UAAWT,EAAUU,OAAW"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
define([],function(){return{help:function(a){var b=$("<div/>").addClass("ui-form-help").append(a.help);return b.find("a").attr("target","_blank"),b},success:function(a){if(!a.jobs||!a.jobs.length)return this.error(a);var b=a.jobs.length,c="";c=1==b?"1 job has":b+" jobs have";var d='<div class="donemessagelarge"><p>'+c+" been successfully added to the queue - resulting in the following datasets:</p>";for(var e in a.outputs)d+='<p style="padding: 10px 20px;"><b>'+a.outputs[e].hid+": "+a.outputs[e].name+"</b></p>";return d+="<p>You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from 'running' to 'finished' if completed successfully or 'error' if problems were encountered.</p></div>"},error:function(a){return'<div><p>The server could not complete the request. Please contact the Galaxy Team if this error persists.</p><textarea class="ui-textarea" disabled style="color: black; height: 300px !important;">'+JSON.stringify(a,void 0,4)+"</textarea></div>"},requirements:function(a){var b="This tool requires ";for(var c in a.requirements){var d=a.requirements[c];b+=d.name,d.version&&(b+=" (Version "+d.version+")"),c<a.requirements.length-2&&(b+=", "),c==a.requirements.length-2&&(b+=" and ")}return b+'. Click <a target="_blank" href="https://wiki.galaxyproject.org/Tools/Requirements">here</a> for more information.'}}});
define([],function(){return{error:function(a){return $("<div>").append($("<p/>").text("The server could not complete the request. Please contact the Galaxy Team if this error persists.")).append($("<textarea/>").addClass("ui-textarea").css({color:"black",height:"300px !important"}).text(JSON.stringify(a,void 0,4)))}}});
//# sourceMappingURL=../../../maps/mvc/tool/tool-template.js.map