3504: CollectionReader accepts arvados object collection uuids. 'arv-put' sets
authorPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 20 Aug 2014 20:33:27 +0000 (16:33 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 20 Aug 2014 20:33:27 +0000 (16:33 -0400)
owner_uuid when collection is created.  Fixed indentation.

sdk/python/arvados/collection.py
sdk/python/arvados/commands/put.py
sdk/python/tests/test_arv_put.py

index 7aed681504702dc3d37477b5f1c838cb5e10f7c6..5b197a3373836fcaf7468c664e5afbe8d6d97ea8 100644 (file)
@@ -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
index 71e31b24184079a00ccfc69ecccdd75b83e97350..eec63c01d4c4bf557c4c5080438b0bb164bdc67e 100644 (file)
@@ -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')
index 5c84c48c25111128aa669aba784b9aac8fc01588..697ca0cb4afaf043d0ddbf09f40976270d5f093b 100644 (file)
@@ -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'])