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"
12 if cr[:container_uuid]
13 ContainerRequest.where(requesting_container_uuid: cr[:container_uuid]).each do |child|
14 nodes[child[:uuid]] = child
17 @svg = ProvenanceHelper::create_provenance_graph nodes,
21 :direction => :top_down,
26 panes = %w(Status Log Provenance Advanced)
27 if @object.andand.state == 'Uncommitted'
28 panes = %w(Inputs) + panes - %w(Log Provenance)
34 generate_provenance(@object)
39 @object.update_attributes! priority: 0
41 redirect_to params[:return_to]
48 @updates ||= params[@object.class.to_s.underscore.singularize.to_sym]
49 input_obj = @updates[:mounts].andand[:"/var/lib/cwl/cwl.input.json"].andand[:content]
51 workflow = @object.mounts[:"/var/lib/cwl/workflow.json"][:content]
52 get_cwl_inputs(workflow).each do |input_schema|
53 if not input_obj.include? cwl_shortname(input_schema[:id])
56 required, primary_type, param_id = cwl_input_info(input_schema)
57 if input_obj[param_id] == ""
58 input_obj[param_id] = nil
59 elsif primary_type == "boolean"
60 input_obj[param_id] = input_obj[param_id] == "true"
61 elsif ["int", "long"].include? primary_type
62 input_obj[param_id] = input_obj[param_id].to_i
63 elsif ["float", "double"].include? primary_type
64 input_obj[param_id] = input_obj[param_id].to_f
65 elsif ["File", "Directory"].include? primary_type
66 re = CollectionsHelper.match_uuid_with_optional_filepath(input_obj[param_id])
68 c = Collection.find(re[1])
69 input_obj[param_id] = {"class" => primary_type,
70 "location" => "keep:#{c.portable_data_hash}#{re[4]}",
71 "arv:collection" => input_obj[param_id]}
80 flash[:error] = e.to_s
88 @object = ContainerRequest.new
90 # By default the copied CR won't be reusing containers, unless use_existing=true
93 if params[:use_existing]
94 @object.use_existing = true
95 # Pass the correct argument to arvados-cwl-runner command.
96 if src.command[0] == 'arvados-cwl-runner'
97 command = src.command - ['--disable-reuse']
98 command.insert(1, '--enable-reuse')
101 @object.use_existing = false
102 # Pass the correct argument to arvados-cwl-runner command.
103 if src.command[0] == 'arvados-cwl-runner'
104 command = src.command - ['--enable-reuse']
105 command.insert(1, '--disable-reuse')
109 @object.command = command
110 @object.container_image = src.container_image
111 @object.cwd = src.cwd
112 @object.description = src.description
113 @object.environment = src.environment
114 @object.mounts = src.mounts
115 @object.name = src.name
116 @object.output_path = src.output_path
118 @object.properties[:template_uuid] = src.properties[:template_uuid]
119 @object.runtime_constraints = src.runtime_constraints
120 @object.scheduling_parameters = src.scheduling_parameters
121 @object.state = 'Uncommitted'
123 # set owner_uuid to that of source, provided it is a project and writable by current user
124 current_project = Group.find(src.owner_uuid) rescue nil
125 if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
126 @object.owner_uuid = src.owner_uuid