From: Peter Amstutz Date: Fri, 9 Dec 2016 15:59:17 +0000 (-0500) Subject: Merge branch '10674-wb-workflow-defaults' closes #10674 X-Git-Tag: 1.1.0~548 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/e336e28f4ce9c13aad98d059d2befb505bff365b?hp=b8e3dea8979a7dbbdb62b8ecd47f7094a7f0863c Merge branch '10674-wb-workflow-defaults' closes #10674 --- diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb index 3b611aa25b..550bdb7e95 100644 --- a/apps/workbench/app/controllers/work_units_controller.rb +++ b/apps/workbench/app/controllers/work_units_controller.rb @@ -57,7 +57,7 @@ class WorkUnitsController < ApplicationController workflow = Workflow.find? template_uuid if workflow.definition begin - wf_json = YAML::load(workflow.definition) + wf_json = ActiveSupport::HashWithIndifferentAccess.new YAML::load(workflow.definition) rescue => e logger.error "Error converting definition yaml to json: #{e.message}" raise ArgumentError, "Error converting definition yaml to json: #{e.message}" @@ -77,11 +77,21 @@ class WorkUnitsController < ApplicationController attrs['cwd'] = "/var/spool/cwl" attrs['output_path'] = "/var/spool/cwl" + input_defaults = {} + if wf_json + inputs = get_cwl_inputs(wf_json) + inputs.each do |input| + if input[:default] + input_defaults[cwl_shortname(input[:id])] = input[:default] + end + end + end + # mounts mounts = { "/var/lib/cwl/cwl.input.json" => { "kind" => "json", - "content" => {} + "content" => input_defaults }, "stdout" => { "kind" => "file", diff --git a/apps/workbench/test/integration/work_units_test.rb b/apps/workbench/test/integration/work_units_test.rb index 3f551a012e..5b5848ee77 100644 --- a/apps/workbench/test/integration/work_units_test.rb +++ b/apps/workbench/test/integration/work_units_test.rb @@ -109,8 +109,8 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest end [ - ['Two Part Pipeline Template', 'part-one', 'Provide a value for the following'], - ['Workflow with input specifications', 'this workflow has inputs specified', 'Provide a value for the following'], + ['Pipeline with default input specifications', 'part-one', 'Provide values for the following'], + ['Workflow with default input specifications', 'this workflow has inputs specified', 'Provide a value for the following'], ].each do |template_name, preview_txt, process_txt| test "run a process using template #{template_name} from dashboard" do visit page_with_token('admin') @@ -131,6 +131,10 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest # in the process page now assert_text process_txt assert_selector 'a', text: template_name + + assert_equal "Set value for ex_string_def", find('div.form-group > div > p.form-control-static > a', text: "hello-testing-123")[:"data-title"] + + page.assert_selector 'a.disabled,button.disabled', text: 'Run' end end diff --git a/services/api/test/fixtures/pipeline_templates.yml b/services/api/test/fixtures/pipeline_templates.yml index cbd82de924..49503c9712 100644 --- a/services/api/test/fixtures/pipeline_templates.yml +++ b/services/api/test/fixtures/pipeline_templates.yml @@ -243,3 +243,25 @@ template_in_asubproject_with_same_name_as_one_in_active_user_home: dataclass: Collection title: "Foo/bar pair" description: "Provide a collection containing at least two files." + +workflow_with_input_defaults: + uuid: zzzzz-p5p6p-aox0k0ofxrystg2 + owner_uuid: zzzzz-j7d0g-v955i6s2oi1cbso + created_at: 2014-04-14 12:35:04 -0400 + updated_at: 2014-04-14 12:35:04 -0400 + modified_at: 2014-04-14 12:35:04 -0400 + modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr + modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz + name: Pipeline with default input specifications + components: + part-one: + script: foo + script_version: master + script_parameters: + ex_string: + required: true + dataclass: string + ex_string_def: + required: true + dataclass: string + default: hello-testing-123 \ No newline at end of file diff --git a/services/api/test/fixtures/workflows.yml b/services/api/test/fixtures/workflows.yml index 4badf9e175..f79320e907 100644 --- a/services/api/test/fixtures/workflows.yml +++ b/services/api/test/fixtures/workflows.yml @@ -44,3 +44,22 @@ workflow_with_input_specifications: inputBinding: position: 1 outputs: [] + +workflow_with_input_defaults: + uuid: zzzzz-7fd4e-validwithinput2 + owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0 + name: Workflow with default input specifications + description: this workflow has inputs specified + created_at: <%= 1.minute.ago.to_s(:db) %> + definition: | + cwlVersion: v1.0 + class: CommandLineTool + baseCommand: + - echo + inputs: + - type: string + id: ex_string + - type: string + id: ex_string_def + default: hello-testing-123 + outputs: []