[ARVADOS] updated: de54cdcea8dca015e3b08bb23f7221faa4814ef0

git at public.curoverse.com git at public.curoverse.com
Fri May 2 10:12:30 EDT 2014


Summary of changes:
 .../app/assets/javascripts/application.js          |    7 +
 .../app/assets/javascripts/collections.js          |   59 ++
 .../app/assets/javascripts/collections.js.coffee   |    3 -
 .../app/assets/stylesheets/collections.css.scss    |   21 +-
 .../app/controllers/collections_controller.rb      |   34 ++-
 apps/workbench/app/controllers/users_controller.rb |   36 +-
 .../app/controllers/websocket_controller.rb        |   10 +
 .../app/views/collections/_index_tbody.html.erb    |   10 +-
 .../app/views/collections/_show_files.html.erb     |   12 +
 .../app/views/collections/_show_recent.html.erb    |    8 +-
 .../app/views/collections/_toggle_persist.html.erb |    3 +
 apps/workbench/app/views/users/_tables.html.erb    |  120 +++--
 apps/workbench/app/views/websocket/index.html.erb  |   34 ++
 apps/workbench/config/routes.rb                    |    5 +-
 .../workbench/test/integration/collections_test.rb |   42 ++
 sdk/cli/bin/arv-run-pipeline-instance              |    4 +-
 sdk/ruby/lib/arvados.rb                            |   36 +-
 services/api/Gemfile                               |    2 +
 services/api/Gemfile.lock                          |    8 +
 .../api/app/controllers/application_controller.rb  |  304 +++--------
 .../app/controllers/arvados/v1/nodes_controller.rb |    2 +-
 .../controllers/arvados/v1/schema_controller.rb    |    6 +
 services/api/app/middlewares/arvados_api_token.rb  |   61 +++
 services/api/app/middlewares/rack_socket.rb        |   86 +++
 .../api/app/models/api_client_authorization.rb     |   12 +
 services/api/app/models/arvados_model.rb           |   96 +++-
 services/api/app/models/blob.rb                    |   19 +-
 services/api/app/models/log.rb                     |    8 +-
 services/api/app/models/node.rb                    |    2 +-
 services/api/config/application.yml.example        |    7 +
 services/api/config/initializers/authorization.rb  |    5 +
 services/api/config/initializers/eventbus.rb       |   18 +
 .../20140423132913_add_object_owner_to_logs.rb     |   27 +
 services/api/db/schema.rb                          |    1 +
 services/api/lib/current_api_client.rb             |   13 -
 services/api/lib/eventbus.rb                       |  226 ++++++++
 services/api/lib/load_param.rb                     |  114 ++++
 services/api/lib/record_filters.rb                 |   75 +++
 .../test/fixtures/api_client_authorizations.yml    |   15 +
 services/api/test/fixtures/logs.yml                |   31 +-
 services/api/test/fixtures/repositories.yml        |    7 +-
 .../functional/arvados/v1/nodes_controller_test.rb |    9 +
 .../api_client_authorizations_scopes_test.rb       |   68 +--
 .../api/test/integration/login_workflow_test.rb    |   25 +
 .../api/test/integration/reader_tokens_test.rb     |   85 +++
 services/api/test/integration/select_test.rb       |   13 +
 services/api/test/integration/websocket_test.rb    |  570 ++++++++++++++++++++
 services/api/test/test_helper.rb                   |   29 +-
 services/api/test/unit/blob_test.rb                |   27 +
 services/api/test/unit/log_test.rb                 |   21 +
 services/api/test/websocket_runner.rb              |   42 ++
 services/keep/src/keep/keep.go                     |  271 +++-------
 services/keep/src/keep/keep_test.go                |  162 +++---
 services/keep/src/keep/volume.go                   |  129 +++++
 services/keep/src/keep/volume_unix.go              |  295 ++++++++++
 services/keep/src/keep/volume_unix_test.go         |  245 +++++++++
 56 files changed, 2868 insertions(+), 712 deletions(-)
 create mode 100644 apps/workbench/app/assets/javascripts/collections.js
 delete mode 100644 apps/workbench/app/assets/javascripts/collections.js.coffee
 create mode 100644 apps/workbench/app/controllers/websocket_controller.rb
 create mode 100644 apps/workbench/app/views/collections/_toggle_persist.html.erb
 create mode 100644 apps/workbench/app/views/websocket/index.html.erb
 create mode 100644 apps/workbench/test/integration/collections_test.rb
 create mode 100644 services/api/app/middlewares/arvados_api_token.rb
 create mode 100644 services/api/app/middlewares/rack_socket.rb
 create mode 100644 services/api/config/initializers/authorization.rb
 create mode 100644 services/api/config/initializers/eventbus.rb
 create mode 100644 services/api/db/migrate/20140423132913_add_object_owner_to_logs.rb
 create mode 100644 services/api/lib/eventbus.rb
 create mode 100644 services/api/lib/load_param.rb
 create mode 100644 services/api/lib/record_filters.rb
 create mode 100644 services/api/test/integration/login_workflow_test.rb
 create mode 100644 services/api/test/integration/reader_tokens_test.rb
 create mode 100644 services/api/test/integration/websocket_test.rb
 create mode 100644 services/api/test/websocket_runner.rb
 create mode 100644 services/keep/src/keep/volume.go
 create mode 100644 services/keep/src/keep/volume_unix.go
 create mode 100644 services/keep/src/keep/volume_unix_test.go

       via  de54cdcea8dca015e3b08bb23f7221faa4814ef0 (commit)
       via  0df7a1c38affbc50a9c7d8834f9822e398860d91 (commit)
       via  7ce745d5645dc49c2833c1c617fd488bf3a62307 (commit)
       via  fb72864bb6f2ee3ca702b914c97d06a76e01ab0d (commit)
       via  cd08497d1c914cd75fd8be08f9f3ef3bc75485f2 (commit)
       via  681496f40864418fc1ee46277941a40d3445107c (commit)
       via  c6068bbeea3ea9bfee45204c2990caef0d4ec1ae (commit)
       via  33b49fa0be7d8e0774c80ec315985dcdf8535962 (commit)
       via  83781a4f423a3671a5ec6d4b1cd6a0bbeacef3a6 (commit)
       via  73d73c7b799ddb60363ddf409d8d301b27c82c00 (commit)
       via  02377152d7e368b6b73b2a94ceb68c99f9d55959 (commit)
       via  a6439c7ddc3407193889386051f06df2a1e74ea9 (commit)
       via  57b46f9b292e561739fde3ea098c366db8f4bc23 (commit)
       via  e8f81804c24307b6702b1897c80b4be832254454 (commit)
       via  1812950e91daaf7a1b02e3777c4e1d483b42d018 (commit)
       via  e87cfcde836ef572a722d645655c7a05fb3f473d (commit)
       via  4fb767326911e01898e5ae28a55a1491b9535b36 (commit)
       via  943feeec776bb75c685cbdee9466f8db3cdf5da7 (commit)
       via  1433693e08e2d4052cc94f6a5902523b08bbc1ac (commit)
       via  e20c9587ad703ae8e1f81251a6e209834a52d448 (commit)
       via  a4724fe92e651abb06acf8c5e75184561a55c854 (commit)
       via  208e172287aba3be7cb988a2c416e4281a2e5f60 (commit)
       via  b0c30631bceb2d1837b52d1d3475e52aee4c9c43 (commit)
       via  840e7d7f96f763ae139545dca5d6dfa5a54f6cc6 (commit)
       via  b421d5c4754315cdd8b70b6bbea5b5f23fb425de (commit)
       via  8adde5132926e8f9cc1b01d79f9307614cc6021e (commit)
       via  8eaad00b025167a7505ba11ad6a05b52a43c2399 (commit)
       via  30f834eef8916c0d613c098a4897ac932a2e0b37 (commit)
       via  c18bde8300e115b215e58d6930d0495b2c33b49f (commit)
       via  4e3ac7f8bafde72ae397f79bfc36409e682b13e5 (commit)
       via  7b9cff04eb463c666b8126ebc6c4dfcc00a536c0 (commit)
       via  f845c0645d9136a1e4ad993ecf34a156367e73b7 (commit)
       via  4ab25f3b39de88d6d2382bb91af9d67bd6de3bd3 (commit)
       via  2ea7a68942928d1d37166726be5114cb7fbdb75b (commit)
       via  f74cbd153b5cbe4e3678c9b86178019f593b553d (commit)
       via  f37f7c068b8d59934c7b0632d531c08470323123 (commit)
       via  e05f165ac12cb54faad707548b8b8f2005f2eef6 (commit)
       via  b860994fa83b9f11b7243220efb8f2fe9b2e2917 (commit)
       via  4fa5a3d3958eae7ecce681e0ea7a4ac8cc43e48d (commit)
       via  a28be6d77750a6cbded994612d95ee973cb4c01e (commit)
       via  58dd340f19c3e0225ad189e60a58872d3aa3f7c2 (commit)
       via  e537bd8dd1ac786164f192374e0d076bdc0327f3 (commit)
       via  995dd33ec5bc9ebb7cc4ff075a1f5e1a4e7db20c (commit)
       via  1c5176d87df0dbd25db6ff1fb2ab82ae17472145 (commit)
       via  5d356c84dcf8f3a2129cce0f4fbfc50f16a8a339 (commit)
       via  4eb42fd91dc5e50840e0d3db5d5201561602a508 (commit)
       via  7c12fc4d989dd2b4c47a174280a4f9526ecb0798 (commit)
       via  f6f07b1856fc0aa32cdf1f96d5bdeb12e9e314ef (commit)
       via  919cf4c2c9f803f0cdb80619bcbf5d23b7c02d25 (commit)
       via  6c0b68255c0c66d90c0473561461d9215860f018 (commit)
       via  9e97504e5f65c8a3a6f1f34da678ac7e1828e8e1 (commit)
       via  62db3393df8d6bc7c48a3c5101468361cb2f3cf3 (commit)
       via  e062efe37ddf066af1c5c762b126bb72766fee25 (commit)
       via  dbce533271fca5a106ab8a00ad2621177445131f (commit)
       via  20334fa95bb7d554c09225c02fae3d4e83c6c6c5 (commit)
       via  0a72fd5c9f764eba4fc295d8beb24ac3d01885c5 (commit)
       via  87f17f28080eef37ad940a039fd1623e72e3058e (commit)
       via  c72f1de32f688690d1161a1852e471e88919e057 (commit)
       via  f0ca76acaa3a4e3713f7aef6a6bb778e6e71e562 (commit)
       via  1f9df3c7140d4eacf58d4e19a7ddc81260296229 (commit)
       via  78b5bfcb1fa832e4460cfaa41f7815ce1d07a9a4 (commit)
       via  93db9aecb724964a37474104243a6d619b56769f (commit)
       via  da3e84a0984d60a2f4bec00672eb766e2e978859 (commit)
       via  aaa65e9d351284278ccb6d3e803fd3dd4f748c31 (commit)
       via  73cf2bb90245787fbbd7c18da51329524c40f6af (commit)
       via  da1614ac6d9b1b2aeba6267b304ce70c1726b608 (commit)
       via  7130989e6493555eba3491cfc9c8dddd1e1a545a (commit)
       via  923e2bd7d962f1a0feefc73ae4f4531c8235a591 (commit)
       via  eca0d3d0a6938e08dde6067c4565754c45f5ebb7 (commit)
       via  04cc77648cc62c73433801475c27ede4ceb76c8b (commit)
       via  fa257c28461627fe6700dd8fd2152e380f8725d4 (commit)
       via  cb52a672642bdec7c6a97868a68bbb9b8daa0efb (commit)
       via  d07a96a0f0c11b98ecc927f0b3e0b052f8ef99f7 (commit)
       via  b66ad0b212a80c117b5b344a715331962d0bfe2d (commit)
       via  e484a466d78c87114779b596d6ecd79f22088ee2 (commit)
       via  aa920f1659aa830861c196617fe664f35b5c12ef (commit)
       via  c283713dc8762c396407f68129fb276dc4a746fc (commit)
       via  4e047434f0c6958db039cf9ab55e3f7f44da44c9 (commit)
       via  7bc20af4935fee1caa566e86a074022f0b60d166 (commit)
       via  8202cb5f1682588e35dcf90519f53d74c06d4aa6 (commit)
      from  b4a9aaa3d68129d6e948dde46cee63cd66597aba (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 de54cdcea8dca015e3b08bb23f7221faa4814ef0
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri May 2 10:12:25 2014 -0400

    Fix for interaction between 'select' and 'order' (SQL requires that order
    fields show up in select when doing select distinct; readable_by does 'select distinct' by default to avoid duplicate rows).

diff --git a/services/api/lib/load_param.rb b/services/api/lib/load_param.rb
index 14dbf1e..69d74f4 100644
--- a/services/api/lib/load_param.rb
+++ b/services/api/lib/load_param.rb
@@ -80,7 +80,7 @@ module LoadParam
       end
     end
     if @orders.empty?
-      @orders << default_orders
+      @orders = default_orders
     end
 
     case params[:select]
@@ -95,10 +95,19 @@ module LoadParam
       end
     end
 
+    if @select
+      # Any ordering columns must be selected when doing select,
+      # otherwise it is an SQL error, so filter out invaliding orderings.
+      @orders.select! { |o|
+        # match select column against order array entry
+        @select.select { |s| /^#{table_name}.#{s}( (asc|desc))?$/.match o }.any?
+      }
+    end
+
     if params[:distinct].is_a? String
       @distinct = params[:distinct]
-      @orders.select! { |o| @select.include? o } if @select
     end
+
   end
 
 
diff --git a/services/api/test/integration/select_test.rb b/services/api/test/integration/select_test.rb
index 522daa7..28651f8 100644
--- a/services/api/test/integration/select_test.rb
+++ b/services/api/test/integration/select_test.rb
@@ -15,4 +15,17 @@ class SelectTest < ActionDispatch::IntegrationTest
     assert_equal json_response['items'].uniq.count, json_response['items'].count
   end
 
+  test "select with order" do
+    get "/arvados/v1/links", {:format => :json, :select => ['uuid'], :order => "uuid asc"}, auth(:active)
+    assert_response :success
+
+    assert json_response['items'].length > 0
+
+    p = ""
+    json_response['items'].each do |i|
+      assert i['uuid'] > p
+      p = i['uuid']
+    end
+  end
+
 end

commit 0df7a1c38affbc50a9c7d8834f9822e398860d91
Merge: b4a9aaa 7ce745d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu May 1 16:26:09 2014 -0400

    Merge remote-tracking branch 'origin/master' into 2035-arv-mount-tags-folders
    
    Conflicts:
    	services/api/app/controllers/application_controller.rb

diff --cc services/api/app/controllers/application_controller.rb
index 8501c86,4b5a27d..30027c8
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@@ -1,32 -1,25 +1,39 @@@
 +module ApiTemplateOverride
 +  def allowed_to_render?(fieldset, field, model, options)
 +    if options[:select]
 +      return options[:select].include? field.to_s
 +    end
 +    super
 +  end
 +end
 +
 +class ActsAsApi::ApiTemplate
 +  prepend ApiTemplateOverride
 +end
 +
+ require 'load_param'
+ require 'record_filters'
+ 
  class ApplicationController < ActionController::Base
    include CurrentApiClient
    include ThemesForRails::ActionController
+   include LoadParam
+   include RecordFilters
+ 
+   ERROR_ACTIONS = [:render_error, :render_not_found]
  
 +
    respond_to :json
    protect_from_forgery
-   around_filter :thread_with_auth_info, :except => [:render_error, :render_not_found]
  
+   before_filter :respond_with_json_by_default
    before_filter :remote_ip
-   before_filter :require_auth_scope, :except => :render_not_found
-   before_filter :catch_redirect_hint
+   before_filter :load_read_auths
+   before_filter :require_auth_scope, except: ERROR_ACTIONS
  
-   before_filter :find_object_by_uuid, :except => [:index, :create,
-                                                   :render_error,
-                                                   :render_not_found]
+   before_filter :catch_redirect_hint
+   before_filter(:find_object_by_uuid,
+                 except: [:index, :create] + ERROR_ACTIONS)
    before_filter :load_limit_offset_order_params, only: [:index, :owned_items]
    before_filter :load_where_param, only: [:index, :owned_items]
    before_filter :load_filters_param, only: [:index, :owned_items]
@@@ -40,10 -32,8 +46,8 @@@
  
    attr_accessor :resource_attrs
  
-   DEFAULT_LIMIT = 100
- 
    def index
 -    @objects.uniq!(&:id)
 +    @objects.uniq!(&:id) if @select.nil? or @select.include? "id"
      if params[:eager] and params[:eager] != '0' and params[:eager] != 0 and params[:eager] != ''
        @objects.each(&:eager_load_associations)
      end
diff --cc services/api/lib/load_param.rb
index 0000000,e01063d..14dbf1e
mode 000000,100644..100644
--- a/services/api/lib/load_param.rb
+++ b/services/api/lib/load_param.rb
@@@ -1,0 -1,88 +1,105 @@@
+ # Mixin module for reading out query parameters from request params.
+ #
+ # Expects:
+ #   +params+ Hash
+ # Sets:
+ #   @where, @filters, @limit, @offset, @orders
+ module LoadParam
+ 
+   # Default limit on number of rows to return in a single query.
+   DEFAULT_LIMIT = 100
+ 
+   # Load params[:where] into @where
+   def load_where_param
+     if params[:where].nil? or params[:where] == ""
+       @where = {}
+     elsif params[:where].is_a? Hash
+       @where = params[:where]
+     elsif params[:where].is_a? String
+       begin
+         @where = Oj.load(params[:where])
+         raise unless @where.is_a? Hash
+       rescue
+         raise ArgumentError.new("Could not parse \"where\" param as an object")
+       end
+     end
+     @where = @where.with_indifferent_access
+   end
+ 
+   # Load params[:filters] into @filters
+   def load_filters_param
+     @filters ||= []
+     if params[:filters].is_a? Array
+       @filters += params[:filters]
+     elsif params[:filters].is_a? String and !params[:filters].empty?
+       begin
+         f = Oj.load params[:filters]
+         raise unless f.is_a? Array
+         @filters += f
+       rescue
+         raise ArgumentError.new("Could not parse \"filters\" param as an array")
+       end
+     end
+   end
+ 
+   def default_orders
+     ["#{table_name}.modified_at desc"]
+   end
+ 
+   # Load params[:limit], params[:offset] and params[:order]
+   # into @limit, @offset, @orders
+   def load_limit_offset_order_params
+     if params[:limit]
+       unless params[:limit].to_s.match(/^\d+$/)
+         raise ArgumentError.new("Invalid value for limit parameter")
+       end
+       @limit = params[:limit].to_i
+     else
+       @limit = DEFAULT_LIMIT
+     end
+ 
+     if params[:offset]
+       unless params[:offset].to_s.match(/^\d+$/)
+         raise ArgumentError.new("Invalid value for offset parameter")
+       end
+       @offset = params[:offset].to_i
+     else
+       @offset = 0
+     end
+ 
+     @orders = []
+     if params[:order]
+       params[:order].split(',').each do |order|
+         attr, direction = order.strip.split " "
+         direction ||= 'asc'
+         if attr.match /^[a-z][_a-z0-9]+$/ and
+             model_class.columns.collect(&:name).index(attr) and
+             ['asc','desc'].index direction.downcase
+           @orders << "#{table_name}.#{attr} #{direction.downcase}"
+         end
+       end
+     end
+     if @orders.empty?
+       @orders << default_orders
+     end
++
++    case params[:select]
++    when Array
++      @select = params[:select]
++    when String
++      begin
++        @select = Oj.load params[:select]
++        raise unless @select.is_a? Array
++      rescue
++        raise ArgumentError.new("Could not parse \"select\" param as an array")
++      end
++    end
++
++    if params[:distinct].is_a? String
++      @distinct = params[:distinct]
++      @orders.select! { |o| @select.include? o } if @select
++    end
+   end
+ 
+ 
+ end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list