From: Peter Amstutz Date: Wed, 20 Aug 2014 20:33:27 +0000 (-0400) Subject: 3504: CollectionReader accepts arvados object collection uuids. 'arv-put' sets X-Git-Tag: 1.1.0~2303^2~11 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/c732e3d38ad324c46c43f9f3790ed7298eb392c2 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 7aed681504..5b197a3373 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 71e31b2418..eec63c01d4 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 5c84c48c25..697ca0cb4a 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'])