[ARVADOS] updated: afabb6c30c449d6139aec344d0912fc2645e2e89
Git user
git at public.curoverse.com
Wed Jun 29 14:22:37 EDT 2016
Summary of changes:
.../app/assets/javascripts/pipeline_instances.js | 2 +-
apps/workbench/app/models/container_work_unit.rb | 14 +++++++++++++
apps/workbench/app/models/work_unit.rb | 8 ++++++++
.../app/views/collections/_show_files.html.erb | 22 +++++++++++---------
.../views/container_requests/_show_log.html.erb | 1 +
.../app/views/containers/_show_log.html.erb | 1 +
.../app/views/work_unit/_show_log.html.erb | 24 ++++++++++++++++++++++
.../container_requests_controller_test.rb | 17 +++++++++++++++
.../test/controllers/containers_controller_test.rb | 15 ++++++++++++++
apps/workbench/test/integration/websockets_test.rb | 9 +++++---
services/api/test/fixtures/containers.yml | 1 +
11 files changed, 100 insertions(+), 14 deletions(-)
create mode 100644 apps/workbench/app/views/container_requests/_show_log.html.erb
create mode 100644 apps/workbench/app/views/containers/_show_log.html.erb
create mode 100644 apps/workbench/app/views/work_unit/_show_log.html.erb
create mode 100644 apps/workbench/test/controllers/container_requests_controller_test.rb
create mode 100644 apps/workbench/test/controllers/containers_controller_test.rb
via afabb6c30c449d6139aec344d0912fc2645e2e89 (commit)
via 8c4542afc387211a36cc90f8085f229ff314854e (commit)
from 1263d931ed5043cb7f71dcfdb0ec8099b6f68501 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit afabb6c30c449d6139aec344d0912fc2645e2e89
Merge: 1263d93 8c4542a
Author: radhika <radhika at curoverse.com>
Date: Wed Jun 29 14:03:55 2016 -0400
closes #9407
Merge branch '9407-container-log-viewer'
commit 8c4542afc387211a36cc90f8085f229ff314854e
Author: radhika <radhika at curoverse.com>
Date: Fri Jun 24 17:16:12 2016 -0400
9407: container log view
diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js
index 8bb25c1..1617a92 100644
--- a/apps/workbench/app/assets/javascripts/pipeline_instances.js
+++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js
@@ -108,7 +108,7 @@ $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(e
}
var wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
- if (eventData.event_type == "stderr" || eventData.event_type == "stdout") {
+ if (eventData.properties != null && eventData.properties.text != null) {
if( eventData.prepend ) {
$(this).prepend(eventData.properties.text);
} else {
diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb
index 037a6e5..f915923 100644
--- a/apps/workbench/app/models/container_work_unit.rb
+++ b/apps/workbench/app/models/container_work_unit.rb
@@ -124,6 +124,20 @@ class ContainerWorkUnit < ProxyWorkUnit
get_combined(:output_path)
end
+ def live_log_lines(limit=2000)
+ event_types = ["stdout", "stderr", "arv-mount", "crunch-run"]
+ log_lines = Log.where(event_type: event_types, object_uuid: uuid).order("id DESC").limit(limit)
+ log_lines.results.reverse.
+ flat_map { |log| log.properties[:text].split("\n") rescue [] }
+ end
+
+ def render_log
+ collection = Collection.find(log_collection) rescue nil
+ if collection
+ return {log: collection, partial: 'collections/show_files', locals: {object: collection, no_checkboxes: true}}
+ end
+ end
+
# End combined propeties
protected
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index 1c2d02f..dee6a60 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -179,4 +179,12 @@ class WorkUnit
def container_uuid
# container_uuid of a container_request
end
+
+ def live_log_lines(limit)
+ # fetch log entries from logs table for @proxied
+ end
+
+ def render_log
+ # return partial and locals to be rendered
+ end
end
diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index e3c79f1..a21a514 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -9,6 +9,8 @@
end
%>
+<% object = @object unless object %>
+
<div class="selection-action-container" style="padding-left: <%=padding_left%>">
<% if Collection.creatable? and (!defined? no_checkboxes or !no_checkboxes) %>
<div class="row">
@@ -19,7 +21,7 @@
<li><%= link_to "Create new collection with selected files", '#',
method: :post,
'data-href' => combine_selected_path(
- action_data: {current_project_uuid: @object.owner_uuid}.to_json
+ action_data: {current_project_uuid: object.owner_uuid}.to_json
),
'data-selection-param-name' => 'selection[]',
'data-selection-action' => 'combine-collections',
@@ -39,7 +41,7 @@
<p/>
<% end %>
- <% file_tree = @object.andand.files_tree %>
+ <% file_tree = object.andand.files_tree %>
<% if file_tree.nil? or file_tree.empty? %>
<p>This collection is empty.</p>
<% else %>
@@ -59,8 +61,8 @@
<ul class="collection_files">
<% else %>
<% link_params = {controller: 'collections', action: 'show_file',
- uuid: @object.portable_data_hash, file: file_path, size: size} %>
- <div class="collection_files_row filterable <%=preview_selectable%>" href="<%=@object.uuid%>/<%=file_path%>">
+ uuid: object.portable_data_hash, file: file_path, size: size} %>
+ <div class="collection_files_row filterable <%=preview_selectable%>" href="<%=object.uuid%>/<%=file_path%>">
<div class="collection_files_buttons pull-right">
<%= raw(human_readable_bytes_html(size)) %>
<%= link_to(raw('<i class="fa fa-search"></i>'),
@@ -73,27 +75,27 @@
<div class="collection_files_name">
<% if (!defined? no_checkboxes or !no_checkboxes) and current_user %>
- <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
+ <%= check_box_tag 'uuids[]', "#{object.uuid}/#{file_path}", false, {
:class => "persistent-selection",
:friendly_type => "File",
- :friendly_name => "#{@object.uuid}/#{file_path}",
+ :friendly_name => "#{object.uuid}/#{file_path}",
:href => url_for(controller: 'collections', action: 'show_file',
- uuid: @object.portable_data_hash, file: file_path),
+ uuid: object.portable_data_hash, file: file_path),
:title => "Include #{file_path} in your selections",
- :id => "#{@object.uuid}_file_#{index}",
+ :id => "#{object.uuid}_file_#{index}",
} %>
<span> </span>
<% end %>
<% if CollectionsHelper::is_image(filename) %>
<i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
<div class="collection_files_inline">
- <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
+ <%= link_to(image_tag("#{url_for object}/#{file_path}"),
link_params.merge(disposition: 'inline'),
{title: file_path}) %>
</div>
</div>
<% else %>
- <i class="fa fa-fw fa-file" href="<%=@object.uuid%>/<%=file_path%>" ></i> <%= filename %></div>
+ <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %></div>
</div>
<% end %>
</li>
diff --git a/apps/workbench/app/views/container_requests/_show_log.html.erb b/apps/workbench/app/views/container_requests/_show_log.html.erb
new file mode 100644
index 0000000..4126f12
--- /dev/null
+++ b/apps/workbench/app/views/container_requests/_show_log.html.erb
@@ -0,0 +1 @@
+<%= render(partial: 'work_unit/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
diff --git a/apps/workbench/app/views/containers/_show_log.html.erb b/apps/workbench/app/views/containers/_show_log.html.erb
new file mode 100644
index 0000000..4126f12
--- /dev/null
+++ b/apps/workbench/app/views/containers/_show_log.html.erb
@@ -0,0 +1 @@
+<%= render(partial: 'work_unit/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
diff --git a/apps/workbench/app/views/work_unit/_show_log.html.erb b/apps/workbench/app/views/work_unit/_show_log.html.erb
new file mode 100644
index 0000000..566da5b
--- /dev/null
+++ b/apps/workbench/app/views/work_unit/_show_log.html.erb
@@ -0,0 +1,24 @@
+<% wu = obj.work_unit(name) %>
+
+<% render_log = wu.render_log %>
+<% if render_log %>
+ <div>
+ <% log_url = url_for render_log[:log] %>
+ <p> <a href="<%= log_url %>">Download the log</a> </p>
+ <%= render(partial: render_log[:partial], locals: render_log[:locals]) %>
+ </div>
+<% end %>
+
+<%# Show log in terminal window %>
+<h4>Recent logs</h4>
+<div id="event_log_div"
+ class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
+ data-object-uuid="<%= wu.uuid %>"
+ ><%= wu.live_log_lines(Rails.configuration.running_job_log_records_to_fetch).join("\n") %>
+</div>
+
+<%# Applying a long throttle suppresses the auto-refresh of this
+ partial that would normally be triggered by arv-log-event. %>
+<div class="arv-log-refresh-control"
+ data-load-throttle="86486400000" <%# 1001 nights %>>
+</div>
diff --git a/apps/workbench/test/controllers/container_requests_controller_test.rb b/apps/workbench/test/controllers/container_requests_controller_test.rb
new file mode 100644
index 0000000..c738343
--- /dev/null
+++ b/apps/workbench/test/controllers/container_requests_controller_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class ContainerRequestsControllerTest < ActionController::TestCase
+ test "visit container_request log" do
+ use_token 'active'
+
+ cr = api_fixture('container_requests')['completed']
+ container_uuid = cr['container_uuid']
+ container = Container.find(container_uuid)
+
+ get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
+ assert_response :success
+
+ assert_select "a", {:href=>"/collections/#{container['log']}", :text=>"Download the log"}
+ assert_select "a", {:href=>"#{container['log']}/baz"}
+ end
+end
diff --git a/apps/workbench/test/controllers/containers_controller_test.rb b/apps/workbench/test/controllers/containers_controller_test.rb
new file mode 100644
index 0000000..ce37239
--- /dev/null
+++ b/apps/workbench/test/controllers/containers_controller_test.rb
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+class ContainersControllerTest < ActionController::TestCase
+ test "visit container log" do
+ use_token 'active'
+
+ container = api_fixture('containers')['completed']
+
+ get :show, {id: container['uuid'], tab_pane: 'Log'}, session_for(:active)
+ assert_response :success
+
+ assert_select "a", {:href=>"/collections/#{container['log']}", :text=>"Download the log"}
+ assert_select "a", {:href=>"#{container['log']}/baz"}
+ end
+end
diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb
index 655ad92..bc8b5cd 100644
--- a/apps/workbench/test/integration/websockets_test.rb
+++ b/apps/workbench/test/integration/websockets_test.rb
@@ -27,9 +27,12 @@ class WebsocketTest < ActionDispatch::IntegrationTest
assert_text '123 hello'
end
-
- [["pipeline_instances", api_fixture("pipeline_instances")['pipeline_with_newer_template']['uuid']],
- ["jobs", api_fixture("jobs")['running']['uuid']]].each do |c|
+ [
+ ["pipeline_instances", api_fixture("pipeline_instances")['pipeline_with_newer_template']['uuid']],
+ ["jobs", api_fixture("jobs")['running']['uuid']],
+ ["containers", api_fixture("containers")['running']['uuid']],
+ ["container_requests", api_fixture("container_requests")['running']['uuid']],
+ ].each do |c|
test "test live logging scrolling #{c[0]}" do
controller = c[0]
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 1796e49..79e472b 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -76,6 +76,7 @@ completed:
finished_at: 2016-01-12 11:12:13.111111111 Z
container_image: test
cwd: test
+ log: ea10d51bcf88862dbcc36eb292017dfd+45
output: zzzzz-4zz18-znfnqtbbv4spc3w
output_path: test
command: ["echo", "hello"]
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list