From: Peter Amstutz Date: Tue, 16 Sep 2014 00:41:26 +0000 (-0400) Subject: 3605: Getting jobs/queue_size from API server works. Fixed server-side X-Git-Tag: 1.1.0~2176^2~11 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/bff8478af0503196b18446f8b909949b618e363f?ds=sidebyside;hp=07a3aa9651168756a6f108821f6ef10ea4ba8144 3605: Getting jobs/queue_size from API server works. Fixed server-side sorting. Date rendering improvements. --- diff --git a/apps/workbench/app/assets/javascripts/dates.js b/apps/workbench/app/assets/javascripts/dates.js index 9e484ce15d..eeb6edea1c 100644 --- a/apps/workbench/app/assets/javascripts/dates.js +++ b/apps/workbench/app/assets/javascripts/dates.js @@ -1,11 +1,23 @@ +jQuery(function($){ $(document).on('ajax:complete arv:pane:loaded ready', function() { - console.log("woble!"); $('[data-utc-date]').each(function(i, elm) { - var re = /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d) UTC/; - var v = $(elm).attr('data-utc-date').match(re); + console.log("woble!"); + var v = $(elm).attr('data-utc-date').match(/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d) UTC/); + if (!v) { + v = $(elm).attr('data-utc-date').match(/(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z/); + } + if (v) { var ts = new Date(Date.UTC(v[1], v[2]-1, v[3], v[4], v[5], v[6])); - $(elm).text(ts.toLocaleTimeString() + " " + ts.toLocaleDateString()); + if ($(elm).attr('data-utc-date-opts') && $(elm).attr('data-utc-date-opts').match(/noseconds/)) { + $(elm).text((ts.getHours() > 12 ? (ts.getHours()-12) : ts.getHours()) + + ":" + (ts.getMinutes() < 10 ? '0' : '') + ts.getMinutes() + + (ts.getHours() > 12 ? " PM " : " AM ") + + ts.toLocaleDateString()); + } else { + $(elm).text(ts.toLocaleTimeString() + " " + ts.toLocaleDateString()); + } } }); }); +}); diff --git a/apps/workbench/app/assets/stylesheets/projects.css.scss b/apps/workbench/app/assets/stylesheets/projects.css.scss index 600a7a3950..d9edfd89fd 100644 --- a/apps/workbench/app/assets/stylesheets/projects.css.scss +++ b/apps/workbench/app/assets/stylesheets/projects.css.scss @@ -54,5 +54,15 @@ div.scroll-20em { } .dashboard-panel-info-row { - margin-bottom: .5em + padding: .5em; + border-radius: .3em; +} + +.x-ellip { + overflow-x: hide; + text-overflow: ellipsis; +} + +.dashboard-panel-info-row:hover { + background-color: #D9EDF7; } \ No newline at end of file diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 3c067fa468..756339e5be 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -694,17 +694,17 @@ class ApplicationController < ActionController::Base helper_method :running_pipelines def running_pipelines - PipelineInstance.order([["started_at", "asc"]]).filter([["state", "=", "RunningOnServer"]]).all.results.reverse + PipelineInstance.order(["started_at asc", "created_at asc"]).filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]]) end helper_method :finished_pipelines def finished_pipelines lim - PipelineInstance.limit(lim).order([["finished_at", "asc"]]).filter([["state", "in", ["Completed", "Failed", "Cancelled"]]]) + PipelineInstance.limit(lim).order(["finished_at desc"]).filter([["state", "in", ["Complete", "Failed", "Paused"]], ["finished_at", "!=", nil]]) end helper_method :recent_collections def recent_collections lim - c = Collection.limit(lim).order([["modified_at", "asc"]]).filter([["owner_uuid", "is_a", "arvados#group"]]) + c = Collection.limit(lim).order(["modified_at desc"]).filter([["owner_uuid", "is_a", "arvados#group"]]) own = {} Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).each do |g| own[g[:uuid]] = g diff --git a/apps/workbench/app/models/job.rb b/apps/workbench/app/models/job.rb index 309cadeb69..ff2eb00e70 100644 --- a/apps/workbench/app/models/job.rb +++ b/apps/workbench/app/models/job.rb @@ -34,6 +34,10 @@ class Job < ArvadosBase arvados_api_client.api "jobs/#{self.uuid}/", "cancel", {} end + def self.queue_size + arvados_api_client.api("jobs/", "queue_size", {"_method"=> "GET"})[:queue_size] rescue 0 + end + def state Job::state(self) end diff --git a/apps/workbench/app/views/application/_pipeline_status_label.html.erb b/apps/workbench/app/views/application/_pipeline_status_label.html.erb index 8abf65b453..9e5b71047b 100644 --- a/apps/workbench/app/views/application/_pipeline_status_label.html.erb +++ b/apps/workbench/app/views/application/_pipeline_status_label.html.erb @@ -4,6 +4,8 @@ failed <% elsif p.state == 'RunningOnServer' || p.state == 'RunningOnClient' %> running +<% elsif p.state == 'Paused' %> + paused <% else %> <% if not p.components.values.any? { |c| c[:job] rescue false } %> not started diff --git a/apps/workbench/app/views/collections/_show_source_summary.html.erb b/apps/workbench/app/views/collections/_show_source_summary.html.erb index ba9e9dfb9f..51f9348450 100644 --- a/apps/workbench/app/views/collections/_show_source_summary.html.erb +++ b/apps/workbench/app/views/collections/_show_source_summary.html.erb @@ -7,10 +7,12 @@ <% pipelines = PipelineInstance.filter([["components", "like", "%#{@object.uuid}%"]]).each do |pipeline| %> <% pipeline.components.each do |cname, c| %> <% if c[:output_uuid] == @object.uuid %> - <%= cname %> component of pipeline <%= link_to_if_arvados_object(pipeline, friendly_name: true) %> + <%= cname %> component of <%= link_to_if_arvados_object(pipeline, friendly_name: true) %> <% if c.andand[:job].andand[:finished_at] %> - finished at <%= c[:job][:finished_at] %> + finished at <%= c[:job][:finished_at] %> <% end %> +
<% end %> <% end %> <% end %> diff --git a/apps/workbench/app/views/projects/_compute_node_summary.html.erb b/apps/workbench/app/views/projects/_compute_node_summary.html.erb new file mode 100644 index 0000000000..9a58d094b9 --- /dev/null +++ b/apps/workbench/app/views/projects/_compute_node_summary.html.erb @@ -0,0 +1,23 @@ +
+ + + + + + + + + + + + + + + + + + + + +
<%= Job.queue_size %><%= nodes.select {|n| n.crunch_worker_state.in? ["busy", "idle"] }.size %><%= nodes.select {|n| n.crunch_worker_state == "busy" }.size %><%= nodes.select {|n| n.crunch_worker_state == "idle" }.size %>
QueueNodesBusyIdle
+
diff --git a/apps/workbench/app/views/projects/index.html.erb b/apps/workbench/app/views/projects/index.html.erb index fad72044f4..e7e87368d6 100644 --- a/apps/workbench/app/views/projects/index.html.erb +++ b/apps/workbench/app/views/projects/index.html.erb @@ -2,7 +2,7 @@
-
Pipelines running +
Active pipelines <%= link_to( choose_pipeline_templates_path( @@ -17,7 +17,7 @@
-
+
<% if running_pipelines.empty? %> No pipelines are currently running. <% end %> @@ -67,7 +67,8 @@
- Started at <%= p[:created_at] %>. + Started at <%= p[:created_at] %>. <% pipeline_time = Time.now - (p[:started_at] || p[:created_at]) %> Active for <%= runtime(pipeline_time, false) %>. @@ -87,44 +88,64 @@
Recently finished pipelines
-
+
<% finished_pipelines(8).each do |p| %>
-
+
<%= link_to_if_arvados_object p, friendly_name: true %>
-
+
<%= render partial: "pipeline_status_label", locals: {p: p}%>
- <% outputs = [] %> - <% p.components.each do |k, c| %> - <% outputs << c[:output_uuid] if c[:output_uuid] %> - <% end %> - <%= outputs %> + <%= p[:modified_at] %>
-
- Finished at <%= p[:modified_at] %>. <% if p[:started_at] and p[:finished_at] %> <% pipeline_time = p[:finished_at] - p[:started_at] %> - Active for <%= runtime(pipeline_time, false) %>. + Active for <%= runtime(pipeline_time, false) %> <% end %> + + + <% outputs = [] %> + <% p.components.each do |k, c| %> + <% outputs << c[:output_uuid] if c[:output_uuid] %> + <% end %> + <% if outputs.size == 0 %> + No output. + <% elsif outputs.size == 1 %> + <%= link_to_if_arvados_object outputs[0], friendly_name: true %> + <% else %> + Outputs + <% end %> +
+ +
+
+ <% outputs.each do |out| %> +
+ <%= link_to_if_arvados_object out, friendly_name: true %> +
+ <% end %> +
+
+
<% end %>
-
+
<% nodes = Node.all %>
- +
<%= render partial: 'compute_node_summary', locals: {nodes: nodes} %> @@ -136,15 +157,17 @@
Recent collections
-
+
<% r = recent_collections(8) %> <% r[:collections].each do |p| %>
<%= link_to_if_arvados_object r[:owners][p[:owner_uuid]], friendly_name: true %>/ - p[:modified_at] + <%= p[:modified_at]%>
-
<%= link_to_if_arvados_object p, friendly_name: true %> +
<%= link_to_if_arvados_object p, friendly_name: true %>
<% end %> diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb index afb516bd48..5a571d4a8b 100644 --- a/services/api/app/controllers/arvados/v1/jobs_controller.rb +++ b/services/api/app/controllers/arvados/v1/jobs_controller.rb @@ -2,8 +2,8 @@ class Arvados::V1::JobsController < ApplicationController accept_attribute_as_json :script_parameters, Hash accept_attribute_as_json :runtime_constraints, Hash accept_attribute_as_json :tasks_summary, Hash - skip_before_filter :find_object_by_uuid, :only => :queue - skip_before_filter :render_404_if_no_object, :only => :queue + skip_before_filter :find_object_by_uuid, :only => [:queue, :queue_size] + skip_before_filter :render_404_if_no_object, :only => [:queue, :queue_size] def create [:repository, :script, :script_version, :script_parameters].each do |r| @@ -163,7 +163,7 @@ class Arvados::V1::JobsController < ApplicationController end def queue_size - render :json => {:queue_size => Job.queue.size} + render :json => {:queue_size => Job.queue.size} end def self._create_requires_parameters