1 class WorkUnitsController < ApplicationController
2 def find_objects_for_index
3 # If it's not the index rows partial display, just return
4 # The /index request will again be invoked to display the
5 # partial at which time, we will be using the objects found.
6 return if !params[:partial]
9 @filters = @filters || []
11 # get next page of pipeline_instances
12 filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
13 pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
15 # get next page of jobs
16 filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
17 jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
19 # get next page of container_requests
20 filters = @filters + [["uuid", "is_a", ["arvados#containerRequest"]]]
21 crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters)
22 @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit)
25 @next_page_filters = next_page_filters('<=')
26 @next_page_href = url_for(partial: :all_processes_rows,
27 filters: @next_page_filters.to_json)
28 preload_links_for_objects(@objects.to_a)
34 def next_page_href with_params={}
39 template_uuid = params['work_unit']['template_uuid']
42 rc = resource_class_for_uuid(template_uuid)
43 if rc == PipelineTemplate
44 model_class = PipelineInstance
45 attrs['pipeline_template_uuid'] = template_uuid
48 workflow = Workflow.find? template_uuid
51 wf_json = YAML::load(workflow.workflow)
53 logger.error "Error converting workflow yaml to json: #{e.message}"
54 raise ArgumentError, "Error converting workflow yaml to json: #{e.message}"
58 model_class = ContainerRequest
60 attrs['name'] = "#{workflow['name']} container" if workflow['name'].present?
61 attrs['properties'] = {'template_uuid' => template_uuid}
63 attrs['state'] = "Uncommitted"
66 attrs['command'] = ["arvados-cwl-runner", "--local", "--api=containers", "/var/lib/cwl/workflow.json", "/var/lib/cwl/cwl.input.json"]
67 attrs['container_image'] = "arvados/jobs"
68 attrs['cwd'] = "/var/spool/cwl"
69 attrs['output_path'] = "/var/spool/cwl"
73 "/var/lib/cwl/cwl.input.json" => {
79 "path" => "/var/spool/cwl/cwl.output.json"
82 "kind" => "collection",
87 mounts["/var/lib/cwl/workflow.json"] = {
92 attrs['mounts'] = mounts
95 runtime_constraints = {
100 attrs['runtime_constraints'] = runtime_constraints
102 raise ArgumentError, "Unsupported template uuid: #{template_uuid}"
105 attrs['owner_uuid'] = params['work_unit']['owner_uuid']
106 @object ||= model_class.new attrs
111 render_error status: 422