class JobWorkUnit < ProxyWorkUnit
def children
# Job tasks
- uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+ uuid = get(:uuid)
tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
items = []
tasks.each do |t|
end
def progress
- state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+ state = get(:state)
if state == 'Complete'
return 1.0
end
- tasks_summary = (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+ tasks_summary = get(:tasks_summary)
failed = tasks_summary[:failed] || 0 rescue 0
done = tasks_summary[:done] || 0 rescue 0
running = tasks_summary[:running] || 0 rescue 0
end
def docker_image
- (self.proxied.docker_image_locator if self.proxied.respond_to?(:docker_image_locator)) || self.proxied[:docker_image_locator]
+ get(:docker_image_locator)
end
def nondeterministic
- (self.proxied.nondeterministic if self.proxied.respond_to?(:nondeterministic)) || self.proxied[:nondeterministic]
+ get(:nondeterministic)
end
def priority
- (self.proxied.priority if self.proxied.respond_to?(:priority)) || self.proxied[:priority]
+ get(:priority)
end
def log_collection
- (self.proxied.log if self.proxied.respond_to?(:log)) || self.proxied[:log]
+ get(:log)
end
def output
- (self.proxied.output if self.proxied.respond_to?(:output)) || self.proxied[:output]
+ get(:output)
+ end
+
+ def can_cancel?
+ true
end
def uri
- uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+ uuid = get(:uuid)
"/jobs/#{uuid}"
end
def child_summary
- (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+ get(:tasks_summary)
end
def title
attr_accessor :lbl
attr_accessor :proxied
+ attr_accessor :unreadable_children
def initialize proxied, label
self.lbl = label
end
def uuid
- (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+ get(:uuid)
end
def modified_by_user_uuid
- (self.proxied.modified_by_user_uuid if self.proxied.respond_to?(:modified_by_user_uuid)) || self.proxied[:modified_by_user_uuid]
+ get(:modified_by_user_uuid)
end
def created_at
- t= (self.proxied.created_at if self.proxied.respond_to?(:created_at)) || self.proxied[:created_at]
- t.to_datetime if t
+ t = get(:created_at)
+ if t.andand.class == String
+ Time.parse t
+ else
+ t
+ end
end
def started_at
- t = (self.proxied.started_at if self.proxied.respond_to?(:started_at)) || self.proxied[:started_at]
- t.to_datetime if t
+ t = get(:started_at)
+ if t.andand.class == String
+ Time.parse t
+ else
+ t
+ end
end
def finished_at
- t = (self.proxied.finished_at if self.proxied.respond_to?(:finished_at)) || self.proxied[:finished_at]
- t.to_datetime if t
+ t = get(:finished_at)
+ if t.andand.class == String
+ Time.parse t
+ else
+ t
+ end
end
def state_label
- state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+ state = get(:state)
if ["Running", "RunningOnServer", "RunningOnClient"].include? state
"Running"
else
end
def state_bootstrap_class
- state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+ state = get(:state)
case state
when 'Complete'
'success'
end
def success?
- state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+ state = get(:state)
if state == 'Complete'
true
elsif state == 'Failed'
end
def parameters
- (self.proxied.script_parameters if self.proxied.respond_to?(:script_parameters)) || self.proxied[:script_parameters]
+ get(:script_parameters)
end
def repository
- (self.proxied.repository if self.proxied.respond_to?(:repository)) || self.proxied[:repository]
+ get(:repository)
end
def script
- (self.proxied.script if self.proxied.respond_to?(:script)) || self.proxied[:script]
+ get(:script)
end
def script_version
- (self.proxied.send(:script_version) if self.proxied.respond_to?(:script_version)) || self.proxied[:script_version]
+ get(:script_version)
end
def supplied_script_version
- (self.proxied.supplied_script_version if self.proxied.respond_to?(:supplied_script_version)) || self.proxied[:supplied_script_version]
+ get(:supplied_script_version)
end
def runtime_constraints
- (self.proxied.runtime_constraints if self.proxied.respond_to?(:runtime_constraints)) || self.proxied[:runtime_constraints]
+ get(:runtime_constraints)
end
def children
def title
"work unit"
end
+
+ def has_unreadable_children
+ self.unreadable_children
+ end
+
+ protected
+
+ def get key
+ if self.proxied.respond_to? key
+ self.proxied.send(key)
+ elsif self.proxied.is_a?(Hash)
+ self.proxied[key]
+ end
+ end
end
<%# Work unit status %>
-<% if wu.state_label %>
- <div class="pull-right" style="padding-left: 1em">
- Current state: <span class="badge badge-<%= wu.state_bootstrap_class %>" data-wu-state="<%= wu.state_label %>">
- <% if wu.state_label == "running" %>
- Active
- <% else %>
- <%= wu.state_label %>
- <% end %>
- </span>
- </div>
-<% end %>
+<div class="container-fluid>
+ <div class="row-fluid">
+ <%# Need additional handling for main object display %>
+ <% if @object.uuid == wu.uuid %>
+ <div class="col-md-2 pull-right">
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <%# column offset 0 %>
+ <% if wu.state_label.in? ["Queued", "Running"] and wu.can_cancel? and @object.editable? %>
+ <div class="col-md-1">
+ <%= form_tag "#{wu.uri}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
+ <%= hidden_field_tag :return_to, url_for(@object) %>
+ <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
+ <% end %>
+ </div>
+ <% end %>
+ <%# column offset 1 %>
+ <div class="pull-right col-md-5 pipeline-instance-spacing">
+ <%= render partial: 'work_unit/progress', locals: {wu: wu} %>
+ </div>
+ </div>
+ </div>
+ </div>
+ <% end %>
-<% if wu.state_label == 'Paused' %>
- <p>
- This <%= wu.title %> is paused. Children that are
- already running will continue to run, but no new work units will be submitted.
- </p>
-<% end %>
+ <div class="col-md-10" >
+ <% if wu.state_label == 'Paused' %>
+ <p>
+ This <%= wu.title %> is paused. Children that are
+ already running will continue to run, but no new work units will be submitted.
+ </p>
+ <% end %>
-<% runningtime = determine_wallclock_runtime(wu.children) %>
+ <% runningtime = determine_wallclock_runtime(wu.children) %>
-<p>
- <% if wu.started_at %>
- This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
- It
- <% if wu.state_label == 'Complete' %>
- completed in
- <% elsif wu.state_label == 'Failed' %>
- failed after
- <% else %>
- has been active for
- <% end %>
+ <p>
+ <% if wu.started_at %>
+ This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
+ It
+ <% if wu.state_label == 'Complete' %>
+ completed in
+ <% elsif wu.state_label == 'Failed' %>
+ failed after
+ <% else %>
+ has been active for
+ <% end %>
- <% walltime = if wu.finished_at then
- wu.finished_at - wu.started_at
- else
- Time.now - wu.started_at
- end %>
+ <% walltime = if wu.finished_at then
+ wu.finished_at - wu.started_at
+ else
+ Time.now - wu.started_at
+ end %>
- <%= if walltime > runningtime
- render_runtime(walltime, false)
- else
- render_runtime(runningtime, false)
- end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
- <% else %>
- <% if wu.state_label %> This <%= wu.title %> is <%= if wu.state_label == 'Running' then 'active' else wu.state_label.downcase end %>. <% end %>
- <% walltime = 0%>
- <% end %>
+ <%= if walltime > runningtime
+ render_runtime(walltime, false)
+ else
+ render_runtime(runningtime, false)
+ end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
+ <% else %>
+ <% if wu.state_label %> This <%= wu.title %> is <%= if wu.state_label == 'Running' then 'active' else wu.state_label.downcase end %>. <% end %>
+ <% walltime = 0%>
+ <% end %>
- <% if wu.state_label == 'Failed' %>
- Check the Log tab for more detail about why it failed.
- <% end %>
-</p>
+ <% if wu.state_label == 'Failed' %>
+ Check the Log tab for more detail about why it failed.
+ <% end %>
+ </p>
-<% if wu.state_label %>
- <p>
- It
- <% if wu.state_label == 'Running' %>
- has run
- <% else %>
- ran
- <% end %>
- for
- <%
- cputime = wu.children.map { |c|
- if c.started_at
- (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
- else
- 0
- end
- }.reduce(:+) || 0 %>
- <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
- (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
- and used
- <%= render_runtime(cputime, false) %>
- of node allocation time (<%= (cputime/runningtime).round(1) %>⨯ scaling).
+ <% if wu.state_label %>
+ <p>
+ It
+ <% if wu.state_label == 'Running' %>
+ has run
+ <% else %>
+ ran
+ <% end %>
+ for
+ <%
+ cputime = wu.children.map { |c|
+ if c.started_at
+ (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
+ else
+ 0
+ end
+ }.reduce(:+) || 0 %>
+ <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
+ (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
+ and used
+ <%= render_runtime(cputime, false) %>
+ of node allocation time (<%= (cputime/runningtime).round(1) %>⨯ scaling).
+ <% end %>
+ </p>
<% end %>
- </p>
-<% end %>
+ </div>
+ </div>
<p>
<%= render(partial: 'work_unit/component_detail', locals: {current_obj: wu}) %>
preload_for_pdhs collections_pdhs if collections_pdhs.any?
%>
-<% @descendent_count = 0 if !@descendent_count %>
-
-<% wu.children.each_with_index do |c, i| %>
- <% @descendent_count += 1 %>
- <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+<% if wu.has_unreadable_children %>
+ <%= render(partial: "pipeline_instances/show_components_json",
+ locals: {error_name: "Unreadable components", backtrace: nil, wu: wu}) %>
+<% else %>
+ <% @descendent_count = 0 if !@descendent_count %>
+ <% wu.children.each_with_index do |c, i| %>
+ <% @descendent_count += 1 %>
+ <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+ <% end %>
<% end %>