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 = JSON.dump(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['properties'] = {'template_uuid' => template_uuid}
62 attrs['state'] = "Uncommitted"
65 attrs['command'] = ["arvados-cwl-runner", "--local", "--api=containers", "/var/lib/cwl/workflow.json", "/var/lib/cwl/cwl.input.json"]
66 attrs['container_image'] = "arvados/jobs"
67 attrs['cwd'] = "/var/spool/cwl"
68 attrs['output_path'] = "/var/spool/cwl"
72 "/var/lib/cwl/cwl.input.json" => {
78 "path" => "/var/spool/cwl/cwl.output.json"
81 "kind" => "collection",
86 mounts["/var/lib/cwl/workflow.json"] = {
89 "class" => "Workflow",
94 attrs['mounts'] = mounts
97 runtime_constraints = {
102 attrs['runtime_constraints'] = runtime_constraints
104 raise ArgumentError, "Unsupported template uuid: #{template_uuid}"
107 attrs['owner_uuid'] = params['work_unit']['owner_uuid']
108 @object ||= model_class.new attrs
113 render_error status: 422