[ARVADOS] updated: 7c78bea1fde0f581e31338e860ecb89ef91285d9

git at public.curoverse.com git at public.curoverse.com
Wed Aug 20 17:10:40 EDT 2014


Summary of changes:
 apps/workbench/app/controllers/projects_controller.rb          |  7 +------
 apps/workbench/app/models/collection.rb                        |  4 ++--
 apps/workbench/app/views/application/_show_attributes.html.erb | 10 ++--------
 apps/workbench/app/views/collections/_show_recent.html.erb     |  2 --
 apps/workbench/app/views/projects/_show_contents_rows.html.erb |  4 +---
 sdk/python/arvados/collection.py                               |  3 +++
 sdk/python/arvados/commands/put.py                             | 10 ++++++++--
 7 files changed, 17 insertions(+), 23 deletions(-)

       via  7c78bea1fde0f581e31338e860ecb89ef91285d9 (commit)
       via  c732e3d38ad324c46c43f9f3790ed7298eb392c2 (commit)
       via  e8566e29473ec12e3ceefbf87a87fac2b116e6d3 (commit)
      from  27697133a18371d692d69569659dd522e7b0fbdd (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 7c78bea1fde0f581e31338e860ecb89ef91285d9
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Aug 20 17:10:37 2014 -0400

    3504: Use preload_links_for_objects in projects_controller.  Use
    self[:portable_data_hash] in collection.rb to avoid recursive definition of
    .uuid and .portable_data_hash.  Revert change to show_attributes.  Removed
    column from collections show_recent.  Reverted python tests to correspond to
    behavior of pre-3036 API server so test pass.

diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index ea9e503..1f4cd3f 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -178,12 +178,7 @@ class ProjectsController < ApplicationController
       @next_page_href = next_page_href(partial: :contents_rows)
     end
 
-    uuids = @objects.map { |ob| ob.uuid }
-    @object_tags = {}
-    Link.limit(uuids.length*20).filter([["head_uuid", "in", uuids], ["link_class", "=", "tag"]]).each do |t|
-      @object_tags[t.head_uuid] ||= []
-      @object_tags[t.head_uuid] << t
-    end
+    preload_links_for_objects(@objects)
   end
 
   def show
diff --git a/apps/workbench/app/models/collection.rb b/apps/workbench/app/models/collection.rb
index 1f3e0dc..78b0c36 100644
--- a/apps/workbench/app/models/collection.rb
+++ b/apps/workbench/app/models/collection.rb
@@ -78,7 +78,7 @@ class Collection < ArvadosBase
 
   def uuid
     if self[:uuid].nil?
-      return self.portable_data_hash
+      return self[:portable_data_hash]
     else
       super
     end
@@ -86,7 +86,7 @@ class Collection < ArvadosBase
 
   def portable_data_hash
     if self[:portable_data_hash].nil?
-      return self.uuid
+      return self[:uuid]
     else
       super
     end
diff --git a/apps/workbench/app/views/application/_show_attributes.html.erb b/apps/workbench/app/views/application/_show_attributes.html.erb
index a2e0548..965ec5a 100644
--- a/apps/workbench/app/views/application/_show_attributes.html.erb
+++ b/apps/workbench/app/views/application/_show_attributes.html.erb
@@ -4,16 +4,10 @@
   </thead>
   <tbody>
     <% @object.attributes_for_display.each do |attr, attrvalue| %>
-      <% if %w(uuid owner_uuid created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at).include? attr.to_s %>
-        <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
-      <% end %>
-    <% end %>
-    <% @object.attributes_for_display.each do |attr, attrvalue| %>
-      <% if not %w(uuid owner_uuid created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at).include? attr.to_s %>
-        <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
-        <% end %>
+    <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
     <% end %>
   </tbody>
 </table>
 
 <% end %>
+
diff --git a/apps/workbench/app/views/collections/_show_recent.html.erb b/apps/workbench/app/views/collections/_show_recent.html.erb
index d624749..d963114 100644
--- a/apps/workbench/app/views/collections/_show_recent.html.erb
+++ b/apps/workbench/app/views/collections/_show_recent.html.erb
@@ -10,7 +10,6 @@
     <col width="10%" />
     <col width="34%" />
     <col width="11%" />
-    <col width="12%" />
     <col width="29%" />
   </colgroup>
   <thead>
@@ -19,7 +18,6 @@
       <th>uuid</th>
       <th>contents</th>
       <th>created at</th>
-      <th>storage</th>
       <th>tags</th>
     </tr>
   </thead>
diff --git a/apps/workbench/app/views/projects/_show_contents_rows.html.erb b/apps/workbench/app/views/projects/_show_contents_rows.html.erb
index c136187..638fe14 100644
--- a/apps/workbench/app/views/projects/_show_contents_rows.html.erb
+++ b/apps/workbench/app/views/projects/_show_contents_rows.html.erb
@@ -30,8 +30,7 @@
       <br>
       <span class="tags-span">
     <span class="removable-tag-container">
-    <% if @object_tags and @object_tags[object.uuid] %>
-      <% @object_tags[object.uuid].each do |tag_link| %>
+    <% links_for_object(object).select{|link|link.link_class=='tag'}.each do |tag_link| %>
         <span class="label label-info" data-tag-link-uuid="<%= tag_link.uuid %>">
           <%= link_to tag_link.name, controller: "links", filters: [["link_class", "=", "tag"], ["name", "=", tag_link.name]].to_json %>
           <% if tag_link.owner_uuid == current_user.uuid or current_user.is_admin %>
@@ -40,7 +39,6 @@
             </span>
           <% end %>
         </span> 
-      <% end %>
     <% end %>
     </span>
     <a class="btn btn-xs btn-info add-tag-button" data-remote-href="<%= url_for(controller: 'links', action: 'create') %>" data-remote-method="post"><i class="glyphicon glyphicon-plus"></i> Tag</a>
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 697ca0c..9bc385d 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -551,8 +551,9 @@ 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(arverr, None)
         self.assertEqual(p.returncode, 0)
+        self.assertEqual(arverr, None)
+        self.assertEqual(arvout.strip(), manifest_uuid)
 
         # The manifest text stored in the API server under the same
         # manifest UUID must use signed locators.
@@ -564,21 +565,22 @@ class ArvPutIntegrationTest(unittest.TestCase):
         os.remove(os.path.join(datadir, "foo"))
         os.rmdir(datadir)
 
-    def run_and_find_collection(self, text, extra_args=[]):
+    def run_and_find_link(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)
-        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]
+        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]
 
     def test_put_collection_with_unnamed_project_link(self):
-        link = self.run_and_find_collection("Test unnamed collection",
-                                            ['--project-uuid', self.PROJECT_UUID])
+        link = self.run_and_find_link("Test unnamed collection",
+                                      ['--project-uuid', self.PROJECT_UUID])
         username = pwd.getpwuid(os.getuid()).pw_name
         self.assertRegexpMatches(
             link['name'],
@@ -586,18 +588,19 @@ class ArvPutIntegrationTest(unittest.TestCase):
 
     def test_put_collection_with_name_and_no_project(self):
         link_name = 'Test Collection Link in home project'
-        collection = self.run_and_find_collection("Test named collection in home project",
-                                                  ['--name', link_name])
-        self.assertEqual(link_name, collection['name'])
+        link = self.run_and_find_link("Test named collection in home project",
+                                      ['--name', link_name])
+        self.assertEqual(link_name, link['name'])
         my_user_uuid = self.current_user()['uuid']
-        self.assertEqual(my_user_uuid, collection['owner_uuid'])
+        self.assertEqual(my_user_uuid, link['tail_uuid'])
+        self.assertEqual(my_user_uuid, link['owner_uuid'])
 
     def test_put_collection_with_named_project_link(self):
         link_name = 'Test auto Collection Link'
-        collection = self.run_and_find_collection("Test named collection",
-                                                  ['--name', link_name,
-                                                   '--project-uuid', self.PROJECT_UUID])
-        self.assertEqual(link_name, collection['name'])
+        link = self.run_and_find_link("Test named collection",
+                                      ['--name', link_name,
+                                       '--project-uuid', self.PROJECT_UUID])
+        self.assertEqual(link_name, link['name'])
 
 
 if __name__ == '__main__':

commit c732e3d38ad324c46c43f9f3790ed7298eb392c2
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Aug 20 16:33:27 2014 -0400

    3504: CollectionReader accepts arvados object collection uuids.  'arv-put' sets
    owner_uuid when collection is created.  Fixed indentation.

diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py
index 7aed681..5b197a3 100644
--- a/sdk/python/arvados/collection.py
+++ b/sdk/python/arvados/collection.py
@@ -96,6 +96,9 @@ class CollectionReader(object):
         if re.match(r'[a-f0-9]{32}(\+\d+)?(\+\S+)*$', manifest_locator_or_text):
             self._manifest_locator = manifest_locator_or_text
             self._manifest_text = None
+        elif re.match(r'[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}$', manifest_locator_or_text):
+            self._manifest_locator = manifest_locator_or_text
+            self._manifest_text = None
         elif re.match(r'(\S+)( [a-f0-9]{32}(\+\d+)(\+\S+)*)+( \d+:\d+:\S+)+\n', manifest_locator_or_text):
             self._manifest_text = manifest_locator_or_text
             self._manifest_locator = None
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 71e31b2..eec63c0 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -448,17 +448,17 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
         collection = arvados.api().collections().create(
             body={
                 'manifest_text': writer.manifest_text(),
+                'owner_uuid': project_link['tail_uuid']
                 },
             ).execute()
 
-        # Print the locator (uuid) of the new collection.
         output = collection['uuid']
         if project_link is not None:
+            # Update collection name
             try:
                 if 'name' in collection:
                     arvados.api().collections().update(uuid=output,
-                                                       body={"owner_uuid": project_link["tail_uuid"],
-                                                             "name": project_link["name"]}).execute()
+                                                       body={"name": project_link["name"]}).execute()
                 else:
                     create_project_link(output, project_link)
             except apiclient.errors.Error as error:
@@ -467,6 +467,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
                         error))
                 status = 1
 
+    # Print the locator (uuid) of the new collection.
     stdout.write(output)
     if not output.endswith('\n'):
         stdout.write('\n')
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 5c84c48..697ca0c 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -578,7 +578,7 @@ class ArvPutIntegrationTest(unittest.TestCase):
 
     def test_put_collection_with_unnamed_project_link(self):
         link = self.run_and_find_collection("Test unnamed collection",
-                                      ['--project-uuid', self.PROJECT_UUID])
+                                            ['--project-uuid', self.PROJECT_UUID])
         username = pwd.getpwuid(os.getuid()).pw_name
         self.assertRegexpMatches(
             link['name'],
@@ -587,7 +587,7 @@ class ArvPutIntegrationTest(unittest.TestCase):
     def test_put_collection_with_name_and_no_project(self):
         link_name = 'Test Collection Link in home project'
         collection = self.run_and_find_collection("Test named collection in home project",
-                                      ['--name', link_name])
+                                                  ['--name', link_name])
         self.assertEqual(link_name, collection['name'])
         my_user_uuid = self.current_user()['uuid']
         self.assertEqual(my_user_uuid, collection['owner_uuid'])
@@ -595,8 +595,8 @@ class ArvPutIntegrationTest(unittest.TestCase):
     def test_put_collection_with_named_project_link(self):
         link_name = 'Test auto Collection Link'
         collection = self.run_and_find_collection("Test named collection",
-                                      ['--name', link_name,
-                                       '--project-uuid', self.PROJECT_UUID])
+                                                  ['--name', link_name,
+                                                   '--project-uuid', self.PROJECT_UUID])
         self.assertEqual(link_name, collection['name'])
 
 

commit e8566e29473ec12e3ceefbf87a87fac2b116e6d3
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__':

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list