end
end
params[:merge] = true
+
+ if !@updates[:reuse_steps].nil?
+ if @updates[:reuse_steps] == "false"
+ @updates[:reuse_steps] = false
+ end
+ @updates[:command] ||= @object.command
+ @updates[:command] -= ["--disable-reuse", "--enable-reuse"]
+ if @updates[:reuse_steps]
+ @updates[:command].insert(1, "--enable-reuse")
+ else
+ @updates[:command].insert(1, "--disable-reuse")
+ end
+ @updates.delete(:reuse_steps)
+ end
+
begin
super
rescue => e
@object = ContainerRequest.new
- # By default the copied CR won't be reusing containers, unless use_existing=true
- # param is passed.
+ # set owner_uuid to that of source, provided it is a project and writable by current user
+ if params[:work_unit].andand[:owner_uuid]
+ @object.owner_uuid = src.owner_uuid = params[:work_unit][:owner_uuid]
+ else
+ current_project = Group.find(src.owner_uuid) rescue nil
+ if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
+ @object.owner_uuid = src.owner_uuid
+ end
+ end
+
command = src.command
- if params[:use_existing]
- @object.use_existing = true
+ if command[0] == 'arvados-cwl-runner'
+ command.each_with_index do |arg, i|
+ if arg.start_with? "--project-uuid="
+ command[i] = "--project-uuid=#{@object.owner_uuid}"
+ end
+ end
+ command -= ["--disable-reuse", "--enable-reuse"]
+ command.insert(1, '--enable-reuse')
+ end
+
+ if params[:use_existing] == "false"
+ params[:use_existing] = false
+ elsif params[:use_existing] == "true"
+ params[:use_existing] = true
+ end
+
+ if params[:use_existing] || params[:use_existing].nil?
+ # If nil, reuse workflow steps but not the workflow runner.
+ @object.use_existing = !!params[:use_existing]
+
# Pass the correct argument to arvados-cwl-runner command.
- if src.command[0] == 'arvados-cwl-runner'
- command = src.command - ['--disable-reuse']
+ if command[0] == 'arvados-cwl-runner'
+ command -= ["--disable-reuse", "--enable-reuse"]
command.insert(1, '--enable-reuse')
end
else
@object.use_existing = false
# Pass the correct argument to arvados-cwl-runner command.
- if src.command[0] == 'arvados-cwl-runner'
- command = src.command - ['--enable-reuse']
+ if command[0] == 'arvados-cwl-runner'
+ command -= ["--disable-reuse", "--enable-reuse"]
command.insert(1, '--disable-reuse')
end
end
@object.scheduling_parameters = src.scheduling_parameters
@object.state = 'Uncommitted'
- # set owner_uuid to that of source, provided it is a project and writable by current user
- current_project = Group.find(src.owner_uuid) rescue nil
- if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
- @object.owner_uuid = src.owner_uuid
- end
-
super
end
end
attrs['command'] = ["arvados-cwl-runner",
+ "--enable-reuse",
"--local",
"--api=containers",
"--project-uuid=#{params['work_unit']['owner_uuid']}",
end
input_type = 'text'
+ opt_selection = nil
attrtype = object.class.attribute_info[attr.to_sym].andand[:type]
if attrtype == 'text' or attr == 'description'
input_type = 'textarea'
elsif attrtype == 'datetime'
input_type = 'date'
+ elsif attrtype == 'boolean'
+ input_type = 'select'
+ opt_selection = ([{value: "true", text: "true"}, {value: "false", text: "false"}]).to_json
else
input_type = 'text'
end
"data-emptytext" => '(none)',
"data-placement" => "bottom",
"data-type" => input_type,
+ "data-source" => opt_selection,
"data-title" => "Edit #{attr.to_s.gsub '_', ' '}",
"data-name" => htmloptions['selection_name'] || attr,
"data-object-uuid" => object.uuid,
def work_unit(label=nil, child_objects=nil)
ContainerWorkUnit.new(self, label, self.uuid, child_objects=child_objects)
end
+
+ def editable_attributes
+ super + ["reuse_steps"]
+ end
+
+ def reuse_steps
+ command.each do |arg|
+ if arg == "--enable-reuse"
+ return true
+ end
+ end
+ false
+ end
+
+ def self.attribute_info
+ self.columns
+ @attribute_info[:reuse_steps] = {:type => "boolean"}
+ @attribute_info
+ end
+
end
}
</script>
- <%= link_to raw('<i class="fa fa-fw fa-play"></i> Re-run...'),
- "#",
- {class: 'btn btn-sm btn-primary', 'data-toggle' => 'modal',
- 'data-target' => '#clone-and-edit-modal-window',
- title: 'This will make a copy and take you there. You can then make any needed changes and run it'} %>
-
-<div id="clone-and-edit-modal-window" class="modal fade" role="dialog"
- aria-labelledby="myModalLabel" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
-
- <%= form_tag copy_container_request_path do |f| %>
-
- <div class="modal-header">
- <button type="button" class="close" onClick="reset_form_cr_reuse()" data-dismiss="modal" aria-hidden="true">×</button>
- <div>
- <div class="col-sm-6"> <h4 class="modal-title">Re-run container request</h4> </div>
- </div>
- <br/>
- </div>
-
- <div class="modal-body">
- <%= check_box_tag(:use_existing, "true", false) %>
- <%= label_tag(:use_existing, "Enable container reuse") %>
- </div>
-
- <div class="modal-footer">
- <button class="btn btn-default" onClick="reset_form_cr_reuse()" data-dismiss="modal" aria-hidden="true">Cancel</button>
- <button type="submit" class="btn btn-primary" name="container_request[state]" value="Uncommitted">Copy and edit inputs</button>
- </div>
-
- </div>
+ <%= link_to(choose_projects_path(id: "run-workflow-button",
+ title: 'Choose project',
+ editable: true,
+ action_name: 'Choose',
+ action_href: copy_container_request_path,
+ action_method: 'post',
+ action_data: {'selection_param' => 'work_unit[owner_uuid]',
+ 'work_unit[template_uuid]' => @object.uuid,
+ 'success' => 'redirect-to-created-object'
+ }.to_json),
+ { class: "btn btn-primary btn-sm", title: "Run #{@object.name}", remote: true }
+ ) do %>
+ <i class="fa fa-fw fa-play"></i> Re-run...
<% end %>
- </div>
-</div>
<% end %>
<% if workflow %>
<% inputs = get_cwl_inputs(workflow) %>
<% inputs.each do |input| %>
- <label for="#input-<%= cwl_shortname(input[:id]) %>">
- <%= input[:label] || cwl_shortname(input[:id]) %>
- </label>
- <div>
- <p class="form-control-static">
- <%= render_cwl_input @object, input, [:mounts, :"/var/lib/cwl/cwl.input.json", :content] %>
+ <div class="form-control-static">
+ <label for="#input-<%= cwl_shortname(input[:id]) %>">
+ <%= input[:label] || cwl_shortname(input[:id]) %>
+ </label>
+ <%= render_cwl_input @object, input, [:mounts, :"/var/lib/cwl/cwl.input.json", :content] %>
+ <p class="help-block">
+ <%= input[:doc] %>
</p>
</div>
- <p class="help-block">
- <%= input[:doc] %>
- </p>
<% end %>
<% end %>
</div>
</form>
<% end %>
+<p style="margin-bottom: 2em"><b style="margin-right: 3em">Reuse past workflow steps if available?</b> <%= render_editable_attribute(@object, :reuse_steps) %></p>
+
<% if n_inputs == 0 %>
<p><i>This workflow does not need any further inputs specified. Click the "Run" button at the bottom of the page to start the workflow.</i></p>
<% else %>
get :show, params: {id: uuid}, session: session_for(:active)
assert_response :success
- assert_includes @response.body, "action=\"/container_requests/#{uuid}/copy\""
+ assert_includes @response.body, "action_href=%2Fcontainer_requests%2F#{uuid}%2Fcopy"
end
test "cancel request for queued container" do
end
[
- ['completed', false, false],
- ['completed', true, false],
+ ['completed', false, false],
+ ['completed', true, false],
+ ['completed', nil, false],
['completed-older', false, true],
- ['completed-older', true, true],
+ ['completed-older', true, true],
+ ['completed-older', nil, true],
].each do |cr_fixture, reuse_enabled, uses_acr|
- test "container request #{uses_acr ? '' : 'not'} using arvados-cwl-runner copy #{reuse_enabled ? 'with' : 'without'} reuse enabled" do
+ test "container request #{uses_acr ? '' : 'not'} using arvados-cwl-runner copy #{reuse_enabled.nil? ? 'nil' : (reuse_enabled ? 'with' : 'without')} reuse enabled" do
completed_cr = api_fixture('container_requests')[cr_fixture]
# Set up post request params
copy_params = {id: completed_cr['uuid']}
- if reuse_enabled
- copy_params.merge!({use_existing: true})
+ if !reuse_enabled.nil?
+ copy_params.merge!({use_existing: reuse_enabled})
end
post(:copy, params: copy_params, session: session_for(:active))
assert_response 302
# If the CR's command is arvados-cwl-runner, the appropriate flag should
# be passed to it
if uses_acr
- if reuse_enabled
- # arvados-cwl-runner's default behavior is to enable reuse
- assert_includes copied_cr['command'], 'arvados-cwl-runner'
+ assert_equal copied_cr['command'][0], 'arvados-cwl-runner'
+ if reuse_enabled.nil? || reuse_enabled
+ assert_includes copied_cr['command'], '--enable-reuse'
assert_not_includes copied_cr['command'], '--disable-reuse'
else
- assert_includes copied_cr['command'], 'arvados-cwl-runner'
assert_includes copied_cr['command'], '--disable-reuse'
assert_not_includes copied_cr['command'], '--enable-reuse'
end
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"]
+ assert_equal "true", find('span[data-name="reuse_steps"]').text
+
+ assert_equal "Set value for ex_string_def", find('div.form-group > div.form-control-static > a', text: "hello-testing-123")[:"data-title"]
page.assert_selector 'a.disabled,button.disabled', text: 'Run'
end