[ARVADOS] created: 2.1.0-24-g801add452

Git user git at public.arvados.org
Wed Oct 21 20:03:58 UTC 2020


        at  801add452adb8804711ee10deff82243913fc9df (commit)


commit 801add452adb8804711ee10deff82243913fc9df
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Wed Oct 21 16:02:12 2020 -0400

    17010: Redesign "Re-run..." button to choose project to run in
    
    Also move workflow step reuse to the "Inputs" tab instead of a modal.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/apps/workbench/app/controllers/container_requests_controller.rb b/apps/workbench/app/controllers/container_requests_controller.rb
index 8ce068198..c42e93375 100644
--- a/apps/workbench/app/controllers/container_requests_controller.rb
+++ b/apps/workbench/app/controllers/container_requests_controller.rb
@@ -121,6 +121,23 @@ class ContainerRequestsController < ApplicationController
       end
     end
     params[:merge] = true
+
+    if !@updates[:reuse_steps].nil?
+      if @updates[:reuse_steps] == "false"
+        @updates[:reuse_steps] = false
+      end
+      @updates[:command] ||= @object.command
+      if @updates[:reuse_steps]
+        @updates[:command] = @updates[:command] - ["--disable-reuse"]
+        @updates[:command].insert(1, '--enable-reuse')
+      else
+        @updates[:command] -= @updates[:command] - ["--enable-reuse"]
+        @updates[:command].insert(1, '--disable-reuse')
+      end
+
+      @updates.delete(:reuse_steps)
+    end
+
     begin
       super
     rescue => e
@@ -134,6 +151,27 @@ class ContainerRequestsController < ApplicationController
 
     @object = ContainerRequest.new
 
+    # set owner_uuid to that of source, provided it is a project and writable by current user
+    if params[:work_unit][: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
+
+    if src.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
+        if arg == "--disable-reuse"
+          command[i] = "--enable-reuse"
+        end
+      end
+    end
+
     # By default the copied CR won't be reusing containers, unless use_existing=true
     # param is passed.
     command = src.command
@@ -167,12 +205,6 @@ class ContainerRequestsController < ApplicationController
     @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
 
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 330d30976..786716eb3 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -247,11 +247,15 @@ module ApplicationHelper
     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
@@ -279,6 +283,7 @@ module ApplicationHelper
       "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,
diff --git a/apps/workbench/app/models/container_request.rb b/apps/workbench/app/models/container_request.rb
index 48920c55e..be97a6cfb 100644
--- a/apps/workbench/app/models/container_request.rb
+++ b/apps/workbench/app/models/container_request.rb
@@ -22,4 +22,24 @@ class ContainerRequest < ArvadosBase
   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
diff --git a/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
index b698c938a..cc5d2dec5 100644
--- a/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
+++ b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
@@ -9,40 +9,19 @@ SPDX-License-Identifier: AGPL-3.0 %>
   }
 </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...(2)
     <% end %>
-  </div>
-</div>
 
 <% end %>
diff --git a/apps/workbench/app/views/container_requests/_show_inputs.html.erb b/apps/workbench/app/views/container_requests/_show_inputs.html.erb
index fd8e36383..07bf7c4d7 100644
--- a/apps/workbench/app/views/container_requests/_show_inputs.html.erb
+++ b/apps/workbench/app/views/container_requests/_show_inputs.html.erb
@@ -17,23 +17,23 @@ n_inputs = if @object.mounts[:"/var/lib/cwl/workflow.json"] && @object.mounts[:"
     <% 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 %>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list