16306: Merge branch 'master'
[arvados.git] / apps / workbench / app / controllers / work_units_controller.rb
index 8527b4d48cb717b941ab376b68255e917c5797a3..237cf2755512f1a54ced262df4c722238935d342 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 class WorkUnitsController < ApplicationController
-  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
-    Rails.configuration.anonymous_user_token and
+  skip_around_action :require_thread_api_token, if: proc { |ctrl|
+    !Rails.configuration.Users.AnonymousUserToken.empty? and
     'show_child_component' == ctrl.action_name
   }
 
@@ -23,14 +23,14 @@ class WorkUnitsController < ApplicationController
     # get next page of pipeline_instances
     if PipelineInstance.api_exists?(:index)
       filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
-      pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
+      pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none")
     end
 
     if params[:show_children]
       # get next page of jobs
       if Job.api_exists?(:index)
         filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
-        jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
+        jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none")
       end
     end
 
@@ -39,7 +39,7 @@ class WorkUnitsController < ApplicationController
     if !params[:show_children]
      filters << ["requesting_container_uuid", "=", nil]
     end
-    crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters)
+    crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none")
     @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit)
 
     if @objects.any?
@@ -85,12 +85,6 @@ class WorkUnitsController < ApplicationController
       attrs['state'] = "Uncommitted"
 
       # required
-      attrs['command'] = ["arvados-cwl-runner",
-                          "--local",
-                          "--api=containers",
-                          "--project-uuid=#{params['work_unit']['owner_uuid']}",
-                          "/var/lib/cwl/workflow.json#main",
-                          "/var/lib/cwl/cwl.input.json"]
       attrs['container_image'] = "arvados/jobs"
       attrs['cwd'] = "/var/spool/cwl"
       attrs['output_path'] = "/var/spool/cwl"
@@ -102,6 +96,7 @@ class WorkUnitsController < ApplicationController
         "API" => true
       }
 
+      keep_cache = 256
       input_defaults = {}
       if wf_json
         main = get_cwl_main(wf_json)
@@ -119,11 +114,26 @@ class WorkUnitsController < ApplicationController
               if hint[:ramMin]
                 runtime_constraints["ram"] = hint[:ramMin] * 1024 * 1024
               end
+              if hint[:keep_cache]
+                keep_cache = hint[:keep_cache]
+              end
+              if hint[:acrContainerImage]
+                attrs['container_image'] = hint[:acrContainerImage]
+              end
             end
           end
         end
       end
 
+      attrs['command'] = ["arvados-cwl-runner",
+                          "--enable-reuse",
+                          "--local",
+                          "--api=containers",
+                          "--project-uuid=#{params['work_unit']['owner_uuid']}",
+                          "--collection-cache-size=#{keep_cache}",
+                          "/var/lib/cwl/workflow.json#main",
+                          "/var/lib/cwl/cwl.input.json"]
+
       # mounts
       mounts = {
         "/var/lib/cwl/cwl.input.json" => {