From c6468f0677002dad4875b2b7cbeb67f018ef5be3 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 11 Dec 2017 21:42:40 +0100 Subject: [PATCH] Add conditional for use_cached_job to workflow run form Surprisingly the API endpoint that is used by the UI is a little different from the `create` endpoint the tests are testing, so this also adds a change in how the `use_cached_job` is passed along. --- .../scripts/mvc/tool/tool-form-composite.js | 25 +++++++++++++++++++ lib/galaxy/workflow/run_request.py | 6 +++++ 2 files changed, 31 insertions(+) diff --git a/client/galaxy/scripts/mvc/tool/tool-form-composite.js b/client/galaxy/scripts/mvc/tool/tool-form-composite.js index 7a143f9555b..4db7cda1d8c 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form-composite.js +++ b/client/galaxy/scripts/mvc/tool/tool-form-composite.js @@ -200,6 +200,7 @@ var View = Backbone.View.extend({ this._renderMessage(); this._renderParameters(); this._renderHistory(); + this._renderUseCachedJob(); _.each(this.steps, step => { self._renderStep(step); }); @@ -311,6 +312,28 @@ var View = Backbone.View.extend({ this._append(this.$steps, this.history_form.$el); }, + /** Render job caching option */ + _renderUseCachedJob: function() { + this.job_options_form = new Form({ + cls: "ui-portlet-narrow", + title: "Job re-use Options", + inputs: [ + { + type: "conditional", + name: "use_cached_job", + test_param: { + name: "check", + label: "BETA: Attempt to reuse jobs with identical parameters?", + type: "boolean", + value: "false", + help: "This may skip executing jobs that you have already run." + }, + } + ] + }); + this._append(this.$steps, this.job_options_form.$el); + }, + /** Render step */ _renderStep: function(step) { var self = this; @@ -497,8 +520,10 @@ var View = Backbone.View.extend({ _submit: function() { var self = this; var history_form_data = this.history_form.data.create(); + var job_options_form_data = this.job_options_form.data.create(); var job_def = { new_history_name: history_form_data["new_history|name"] ? history_form_data["new_history|name"] : null, + use_cached_job: true ? job_options_form_data["use_cached_job|check"] === 'true' : false, history_id: !history_form_data["new_history|name"] ? this.model.get("history_id") : null, replacement_params: this.wp_form ? this.wp_form.data.create() : {}, parameters: {}, diff --git a/lib/galaxy/workflow/run_request.py b/lib/galaxy/workflow/run_request.py index 47611f4c86a..fca6a3e199a 100644 --- a/lib/galaxy/workflow/run_request.py +++ b/lib/galaxy/workflow/run_request.py @@ -347,6 +347,7 @@ def workflow_run_config_to_request(trans, run_config, workflow): target_history=run_config.target_history, replacement_dict=run_config.replacement_dict, copy_inputs_to_history=False, + use_cached_job=run_config.use_cached_job, inputs={}, param_map={}, allow_tool_state_corrections=run_config.allow_tool_state_corrections @@ -372,6 +373,7 @@ def workflow_run_config_to_request(trans, run_config, workflow): workflow_invocation.add_input(content, step_id) add_parameter("copy_inputs_to_history", "true" if run_config.copy_inputs_to_history else "false", param_types.META_PARAMETERS) + add_parameter("use_cached_job", "true" if run_config.use_cached_job else "false", param_types.META_PARAMETERS) return workflow_invocation @@ -382,6 +384,7 @@ def workflow_request_to_run_config(work_request_context, workflow_invocation): inputs = {} param_map = {} copy_inputs_to_history = None + use_cached_job = False for parameter in workflow_invocation.input_parameters: parameter_type = parameter.type @@ -390,6 +393,8 @@ def workflow_request_to_run_config(work_request_context, workflow_invocation): elif parameter_type == param_types.META_PARAMETERS: if parameter.name == "copy_inputs_to_history": copy_inputs_to_history = (parameter.value == "true") + if parameter.name == 'use_cached_job': + use_cached_job = (parameter.value == 'true') for input_association in workflow_invocation.input_datasets: inputs[input_association.workflow_step_id] = input_association.dataset for input_association in workflow_invocation.input_dataset_collections: @@ -404,6 +409,7 @@ def workflow_request_to_run_config(work_request_context, workflow_invocation): inputs=inputs, param_map=param_map, copy_inputs_to_history=copy_inputs_to_history, + use_cached_job=use_cached_job, ) return workflow_run_config