X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/921e5feb0deff2f1b420e867faf79a4ecd293350..c7d692a3f09d8116cc52591f8852c4e0d6e4ab3c:/apps/workbench/app/controllers/work_units_controller.rb diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb index d2896821b2..0f0033ce49 100644 --- a/apps/workbench/app/controllers/work_units_controller.rb +++ b/apps/workbench/app/controllers/work_units_controller.rb @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0 class WorkUnitsController < ApplicationController - skip_around_filter :require_thread_api_token, if: proc { |ctrl| + skip_around_action :require_thread_api_token, if: proc { |ctrl| Rails.configuration.anonymous_user_token and 'show_child_component' == ctrl.action_name } @@ -85,21 +85,51 @@ class WorkUnitsController < ApplicationController attrs['state'] = "Uncommitted" # required - attrs['command'] = ["arvados-cwl-runner", "--local", "--api=containers", "/var/lib/cwl/workflow.json#main", "/var/lib/cwl/cwl.input.json"] attrs['container_image'] = "arvados/jobs" attrs['cwd'] = "/var/spool/cwl" attrs['output_path'] = "/var/spool/cwl" + # runtime constriants + runtime_constraints = { + "vcpus" => 1, + "ram" => 1024 * 1024 * 1024, + "API" => true + } + + keep_cache = 256 input_defaults = {} if wf_json - inputs = get_cwl_inputs(wf_json) - inputs.each do |input| + main = get_cwl_main(wf_json) + main[:inputs].each do |input| if input[:default] input_defaults[cwl_shortname(input[:id])] = input[:default] end end + if main[:hints] + main[:hints].each do |hint| + if hint[:class] == "http://arvados.org/cwl#WorkflowRunnerResources" + if hint[:coresMin] + runtime_constraints["vcpus"] = hint[:coresMin] + end + if hint[:ramMin] + runtime_constraints["ram"] = hint[:ramMin] * 1024 * 1024 + end + if hint[:keep_cache] + keep_cache = hint[:keep_cache] + end + end + end + end end + attrs['command'] = ["arvados-cwl-runner", + "--local", + "--api=containers", + "--project-uuid=#{params['work_unit']['owner_uuid']}", + "--collection-cache-size=#{keep_cache}", + "/var/lib/cwl/workflow.json#main", + "/var/lib/cwl/cwl.input.json"] + # mounts mounts = { "/var/lib/cwl/cwl.input.json" => { @@ -123,12 +153,6 @@ class WorkUnitsController < ApplicationController end attrs['mounts'] = mounts - # runtime constriants - runtime_constraints = { - "vcpus" => 1, - "ram" => 256000000, - "API" => true - } attrs['runtime_constraints'] = runtime_constraints else raise ArgumentError, "Unsupported template uuid: #{template_uuid}"