@object = ContainerRequest.new
- if params[:no_reuse]
+ # By default the copied CR won't be reusing jobs, unless use_existing=true param
+ # is passed.
+ command = src.command
+ if params[:use_existing]
+ @object.use_existing = true
+ # Pass the correct argument to arvados-cwl-runner command.
+ if src.command[0] == 'arvados-cwl-runner'
+ command = src.command - ['--disable-reuse']
+ command.insert(1, '--enable-reuse')
+ end
+ else
@object.use_existing = false
- # If "no reuse" requested, pass the correct argument to arvados-cwl-runner command.
+ # Pass the correct argument to arvados-cwl-runner command.
if src.command[0] == 'arvados-cwl-runner'
command = src.command - ['--enable-reuse']
command.insert(1, '--disable-reuse')
end
- else
- command = src.command
end
@object.command = command
@object.runtime_constraints = src.runtime_constraints
@object.scheduling_parameters = src.scheduling_parameters
@object.state = 'Uncommitted'
- @object.use_existing = false
# 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
</div>
<div class="modal-body">
- <%= check_box_tag(:no_reuse, "true", false) %>
- <%= label_tag(:script_use_latest, "Disable container reuse") %>
+ <%= check_box_tag(:use_existing, "true", false) %>
+ <%= label_tag(:use_existing, "Enable container reuse") %>
</div>
<div class="modal-footer">
assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
assert_equal completed_cr['cmd'], copied_cr['cmd']
assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
+ refute copied_cr[:use_existing]
end
- test "container request copy without reuse" do
+ test "container request copy with reuse enabled" do
completed_cr = api_fixture('container_requests')['completed']
- post(:copy, {id: completed_cr['uuid']}, session_for(:active))
+ post(:copy,
+ {
+ id: completed_cr['uuid'],
+ use_existing: true,
+ },
+ session_for(:active))
assert_response 302
copied_cr = assigns(:object)
assert_not_nil copied_cr
- refute copied_cr['use_existing']
+ assert copied_cr['use_existing']
end
end