1 class ContainerRequestsController < ApplicationController
2 skip_around_filter :require_thread_api_token, if: proc { |ctrl|
3 Rails.configuration.anonymous_user_token and
4 'show' == ctrl.action_name
7 def generate_provenance(cr)
8 return if params['tab_pane'] != "Provenance"
10 nodes = {cr[:uuid] => cr}
11 @svg = ProvenanceHelper::create_provenance_graph nodes,
15 :direction => :top_down,
20 panes = %w(Status Log Provenance Advanced)
21 if @object.andand.state == 'Uncommitted'
22 panes = %w(Inputs) + panes - %w(Log Provenance)
28 generate_provenance(@object)
33 @object.update_attributes! priority: 0
35 redirect_to params[:return_to]
42 @updates ||= params[@object.class.to_s.underscore.singularize.to_sym]
43 input_obj = @updates[:mounts].andand[:"/var/lib/cwl/cwl.input.json"].andand[:content]
45 workflow = @object.mounts[:"/var/lib/cwl/workflow.json"][:content]
46 get_cwl_inputs(workflow).each do |input_schema|
47 if not input_obj.include? cwl_shortname(input_schema[:id])
50 required, primary_type, param_id = cwl_input_info(input_schema)
51 if input_obj[param_id] == ""
52 input_obj[param_id] = nil
53 elsif primary_type == "boolean"
54 input_obj[param_id] = input_obj[param_id] == "true"
55 elsif ["int", "long"].include? primary_type
56 input_obj[param_id] = input_obj[param_id].to_i
57 elsif ["float", "double"].include? primary_type
58 input_obj[param_id] = input_obj[param_id].to_f
59 elsif ["File", "Directory"].include? primary_type
60 re = CollectionsHelper.match_uuid_with_optional_filepath(input_obj[param_id])
62 c = Collection.find(re[1])
63 input_obj[param_id] = {"class" => primary_type,
64 "location" => "keep:#{c.portable_data_hash}#{re[4]}",
65 "arv:collection" => input_obj[param_id]}
74 flash[:error] = e.to_s
82 @object = ContainerRequest.new
84 # By default the copied CR won't be reusing containers, unless use_existing=true
87 if params[:use_existing]
88 @object.use_existing = true
89 # Pass the correct argument to arvados-cwl-runner command.
90 if src.command[0] == 'arvados-cwl-runner'
91 command = src.command - ['--disable-reuse']
92 command.insert(1, '--enable-reuse')
95 @object.use_existing = false
96 # Pass the correct argument to arvados-cwl-runner command.
97 if src.command[0] == 'arvados-cwl-runner'
98 command = src.command - ['--enable-reuse']
99 command.insert(1, '--disable-reuse')
103 @object.command = command
104 @object.container_image = src.container_image
105 @object.cwd = src.cwd
106 @object.description = src.description
107 @object.environment = src.environment
108 @object.mounts = src.mounts
109 @object.name = src.name
110 @object.output_path = src.output_path
112 @object.properties[:template_uuid] = src.properties[:template_uuid]
113 @object.runtime_constraints = src.runtime_constraints
114 @object.scheduling_parameters = src.scheduling_parameters
115 @object.state = 'Uncommitted'
117 # set owner_uuid to that of source, provided it is a project and writable by current user
118 current_project = Group.find(src.owner_uuid) rescue nil
119 if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
120 @object.owner_uuid = src.owner_uuid