[ARVADOS] updated: d08c3a56c462a0277aba6f67e0551214f1510102

git at public.curoverse.com git at public.curoverse.com
Tue Aug 19 22:10:13 EDT 2014


Summary of changes:
 sdk/python/arvados/commands/put.py                 |  7 ++++-
 sdk/python/tests/test_arv_put.py                   | 27 ++++++++----------
 .../arvados/v1/collections_controller.rb           | 13 +++++++--
 services/api/app/models/collection.rb              |  1 +
 services/api/lib/current_api_client.rb             |  8 ++----
 .../api/test/integration/collections_api_test.rb   | 33 ++++++++++++++++++++++
 6 files changed, 65 insertions(+), 24 deletions(-)

       via  d08c3a56c462a0277aba6f67e0551214f1510102 (commit)
       via  57d7ce9de300d1340ed12d61248e7cea6bd1be15 (commit)
      from  cbe594f580c26381d786d7b43d5227eb1d12620d (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 d08c3a56c462a0277aba6f67e0551214f1510102
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Aug 19 22:10:10 2014 -0400

    3036: Fix arv-put to write name/owner of collections object directly when
    'name' field is present on the returned object.  Python SDK tests pass.

diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 335ef17..71e31b2 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -455,7 +455,12 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
         output = collection['uuid']
         if project_link is not None:
             try:
-                create_project_link(output, project_link)
+                if 'name' in collection:
+                    arvados.api().collections().update(uuid=output,
+                                                       body={"owner_uuid": project_link["tail_uuid"],
+                                                             "name": project_link["name"]}).execute()
+                else:
+                    create_project_link(output, project_link)
             except apiclient.errors.Error as error:
                 print >>stderr, (
                     "arv-put: Error adding Collection to project: {}.".format(
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 9bc385d..5c84c48 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -551,9 +551,8 @@ class ArvPutIntegrationTest(unittest.TestCase):
         p = subprocess.Popen([sys.executable, arv_put.__file__, datadir],
                              stdout=subprocess.PIPE, env=self.ENVIRON)
         (arvout, arverr) = p.communicate()
-        self.assertEqual(p.returncode, 0)
         self.assertEqual(arverr, None)
-        self.assertEqual(arvout.strip(), manifest_uuid)
+        self.assertEqual(p.returncode, 0)
 
         # The manifest text stored in the API server under the same
         # manifest UUID must use signed locators.
@@ -565,21 +564,20 @@ class ArvPutIntegrationTest(unittest.TestCase):
         os.remove(os.path.join(datadir, "foo"))
         os.rmdir(datadir)
 
-    def run_and_find_link(self, text, extra_args=[]):
+    def run_and_find_collection(self, text, extra_args=[]):
         self.authorize_with('active')
         pipe = subprocess.Popen(
             [sys.executable, arv_put.__file__] + extra_args,
             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
             stderr=subprocess.PIPE, env=self.ENVIRON)
         stdout, stderr = pipe.communicate(text)
-        link_list = arvados.api('v1', cache=False).links().list(
-            filters=[['head_uuid', '=', stdout.strip()],
-                     ['link_class', '=', 'name']]).execute().get('items', [])
-        self.assertEqual(1, len(link_list))
-        return link_list[0]
+        collection_list = arvados.api('v1', cache=False).collections().list(
+            filters=[['uuid', '=', stdout.strip()]]).execute().get('items', [])
+        self.assertEqual(1, len(collection_list))
+        return collection_list[0]
 
     def test_put_collection_with_unnamed_project_link(self):
-        link = self.run_and_find_link("Test unnamed collection",
+        link = self.run_and_find_collection("Test unnamed collection",
                                       ['--project-uuid', self.PROJECT_UUID])
         username = pwd.getpwuid(os.getuid()).pw_name
         self.assertRegexpMatches(
@@ -588,19 +586,18 @@ class ArvPutIntegrationTest(unittest.TestCase):
 
     def test_put_collection_with_name_and_no_project(self):
         link_name = 'Test Collection Link in home project'
-        link = self.run_and_find_link("Test named collection in home project",
+        collection = self.run_and_find_collection("Test named collection in home project",
                                       ['--name', link_name])
-        self.assertEqual(link_name, link['name'])
+        self.assertEqual(link_name, collection['name'])
         my_user_uuid = self.current_user()['uuid']
-        self.assertEqual(my_user_uuid, link['tail_uuid'])
-        self.assertEqual(my_user_uuid, link['owner_uuid'])
+        self.assertEqual(my_user_uuid, collection['owner_uuid'])
 
     def test_put_collection_with_named_project_link(self):
         link_name = 'Test auto Collection Link'
-        link = self.run_and_find_link("Test named collection",
+        collection = self.run_and_find_collection("Test named collection",
                                       ['--name', link_name,
                                        '--project-uuid', self.PROJECT_UUID])
-        self.assertEqual(link_name, link['name'])
+        self.assertEqual(link_name, collection['name'])
 
 
 if __name__ == '__main__':

commit 57d7ce9de300d1340ed12d61248e7cea6bd1be15
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Aug 19 22:09:02 2014 -0400

    3036: Fix #updating collection objects.  Fixed database seed for empty_collection.

diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb
index 77bef08..e58b2e0 100644
--- a/services/api/app/controllers/arvados/v1/collections_controller.rb
+++ b/services/api/app/controllers/arvados/v1/collections_controller.rb
@@ -5,6 +5,11 @@ class Arvados::V1::CollectionsController < ApplicationController
                         status: :unprocessable_entity)
     end
 
+    if resource_attrs[:uuid] and (loc = Locator.parse(resource_attrs[:uuid]))
+      resource_attrs[:portable_data_hash] = loc.to_s
+      resource_attrs.delete :uuid
+    end
+
     # Check permissions on the collection manifest.
     # If any signature cannot be verified, return 403 Permission denied.
     api_token = current_api_client_authorization.andand.api_token
@@ -210,8 +215,12 @@ class Arvados::V1::CollectionsController < ApplicationController
 
   def find_objects_for_index
     # Omit manifest_text from index results unless expressly selected.
-    @select ||= model_class.api_accessible_attributes(:user).
-      map { |attr_spec| attr_spec.first.to_s } - ["manifest_text"]
+    if @select.nil?
+      @select = model_class.api_accessible_attributes(:user).map { |attr_spec|attr_spec.first.to_s }
+      @select -= ["manifest_text"]
+      # have to make sure 'id' column is included or #update will break.
+      @select += ["id"]
+    end
     super
   end
 
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index c0c2b7e..520f617 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -19,6 +19,7 @@ class Collection < ArvadosModel
   def self.attributes_required_columns
     super.merge({ "data_size" => ["manifest_text"],
                   "files" => ["manifest_text"],
+                  "id" => ["id"]
                 })
   end
 
diff --git a/services/api/lib/current_api_client.rb b/services/api/lib/current_api_client.rb
index 7bd4752..6d85212 100644
--- a/services/api/lib/current_api_client.rb
+++ b/services/api/lib/current_api_client.rb
@@ -167,12 +167,8 @@ module CurrentApiClient
       act_as_system_user do
         ActiveRecord::Base.transaction do
           $empty_collection = Collection.
-            where(uuid: empty_collection_uuid).
-            first_or_create!(manifest_text: '')
-          Link.where(tail_uuid: anonymous_group.uuid,
-                     head_uuid: empty_collection_uuid,
-                     link_class: 'permission',
-                     name: 'can_read').first_or_create!
+            where(portable_data_hash: empty_collection_uuid).
+            first_or_create!(manifest_text: '', owner_uuid: anonymous_group.uuid)
         end
       end
     end
diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index 5d06c0a..7680592 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -101,4 +101,37 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
   end
 
+  test "store collection then update name" do
+    signing_opts = {
+      key: Rails.configuration.blob_signing_key,
+      api_token: api_token(:active),
+    }
+    signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44',
+                                       signing_opts)
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+    }, auth(:active)
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
+
+    put "/arvados/v1/collections/#{json_response['uuid']}", {
+      format: :json,
+      collection: { name: "a name" }
+    }, auth(:active)
+
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
+    assert_equal 'a name', json_response['name']
+
+    get "/arvados/v1/collections/#{json_response['uuid']}", {
+      format: :json,
+    }, auth(:active)
+
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
+    assert_equal 'a name', json_response['name']
+  end
+
+
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list