13773: Show 'Warning' label on jobs that have this runtime status and aren't failing.
[arvados.git] / apps / workbench / app / models / job_work_unit.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class JobWorkUnit < ProxyWorkUnit
6   def children
7     return @my_children if @my_children
8
9     # Jobs components
10     items = []
11     components = get(:components)
12     uuids = components.andand.collect {|_, v| v}
13     return items if (!uuids or uuids.empty?)
14
15     rcs = {}
16     uuids.each do |u|
17       r = ArvadosBase::resource_class_for_uuid(u)
18       rcs[r] = [] unless rcs[r]
19       rcs[r] << u
20     end
21     rcs.each do |rc, ids|
22       rc.where(uuid: ids).each do |obj|
23         items << obj.work_unit(components.key(obj.uuid))
24       end
25     end
26
27     @my_children = items
28   end
29
30   def child_summary
31     if children.any?
32       super
33     else
34       get(:tasks_summary)
35     end
36   end
37
38   def parameters
39     get(:script_parameters)
40   end
41
42   def repository
43     get(:repository)
44   end
45
46   def script
47     get(:script)
48   end
49
50   def script_version
51     get(:script_version)
52   end
53
54   def supplied_script_version
55     get(:supplied_script_version)
56   end
57
58   def docker_image
59     get(:docker_image_locator)
60   end
61
62   def nondeterministic
63     get(:nondeterministic)
64   end
65
66   def runtime_constraints
67     get(:runtime_constraints)
68   end
69
70   def priority
71     get(:priority)
72   end
73
74   def log_collection
75     get(:log)
76   end
77
78   def outputs
79     items = []
80     items << get(:output) if get(:output)
81     items
82   end
83
84   def can_cancel?
85     state_label.in? ["Queued", "Running"]
86   end
87
88   def confirm_cancellation
89     "All unfinished child jobs and pipelines will also be canceled, even if they are being used in another job or pipeline. Are you sure you want to cancel this job?"
90   end
91
92   def uri
93     uuid = get(:uuid)
94     "/jobs/#{uuid}"
95   end
96
97   def title
98     "job"
99   end
100 end