[ARVADOS] updated: 21cdefdc8e08ff0132badeb2b81f63614244040f

git at public.curoverse.com git at public.curoverse.com
Thu Sep 18 15:31:24 EDT 2014


Summary of changes:
 sdk/python/arvados/collection.py | 35 +++++++++++++++++++++++++++++++++++
 sdk/python/bin/arv-get           | 17 ++++++++++-------
 2 files changed, 45 insertions(+), 7 deletions(-)

       via  21cdefdc8e08ff0132badeb2b81f63614244040f (commit)
       via  8997f246aa6d7b9c1a3d662b61f2188eabf4c451 (commit)
      from  c19503ef39f3588e3fe2113816e84c0e8dce4074 (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 21cdefdc8e08ff0132badeb2b81f63614244040f
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Sep 18 15:29:17 2014 -0400

    Collections fixup: Add docstrings about num_retries.

diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py
index aa4973a..782e85c 100644
--- a/sdk/python/arvados/collection.py
+++ b/sdk/python/arvados/collection.py
@@ -108,6 +108,25 @@ class CollectionBase(object):
 class CollectionReader(CollectionBase):
     def __init__(self, manifest_locator_or_text, api_client=None,
                  keep_client=None, num_retries=0):
+        """Instantiate a CollectionReader.
+
+        This class parses Collection manifests to provide a simple interface
+        to read its underlying files.
+
+        Arguments:
+        * manifest_locator_or_text: One of a Collection UUID, portable data
+          hash, or full manifest text.
+        * api_client: The API client to use to look up Collections.  If not
+          provided, CollectionReader will build one from available Arvados
+          configuration.
+        * keep_client: The KeepClient to use to download Collection data.
+          If not provided, CollectionReader will build one from available
+          Arvados configuration.
+        * num_retries: The default number of times to retry failed
+          service requests.  Default 0.  You may change this value
+          after instantiation, but note those changes may not
+          propagate to related objects like the Keep client.
+        """
         self._api_client = api_client
         self._keep_client = keep_client
         self.num_retries = num_retries
@@ -188,6 +207,22 @@ class CollectionWriter(CollectionBase):
     KEEP_BLOCK_SIZE = 2**26
 
     def __init__(self, api_client=None, num_retries=0):
+        """Instantiate a CollectionWriter.
+
+        CollectionWriter lets you build a new Arvados Collection from scratch.
+        Write files to it.  The CollectionWriter will upload data to Keep as
+        appropriate, and provide you with the Collection manifest text when
+        you're finished.
+
+        Arguments:
+        * api_client: The API client to use to look up Collections.  If not
+          provided, CollectionReader will build one from available Arvados
+          configuration.
+        * num_retries: The default number of times to retry failed
+          service requests.  Default 0.  You may change this value
+          after instantiation, but note those changes may not
+          propagate to related objects like the Keep client.
+        """
         self._api_client = api_client
         self.num_retries = num_retries
         self._keep_client = None

commit 8997f246aa6d7b9c1a3d662b61f2188eabf4c451
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Sep 18 15:10:37 2014 -0400

    arv-get fixup: Prevent race condition, better error reporting.

diff --git a/sdk/python/bin/arv-get b/sdk/python/bin/arv-get
index ccf8442..38a9823 100755
--- a/sdk/python/bin/arv-get
+++ b/sdk/python/bin/arv-get
@@ -130,14 +130,17 @@ reader = arvados.CollectionReader(collection, num_retries=args.retries)
 
 if not get_prefix:
     if not args.n:
+        open_flags = os.O_CREAT | os.O_WRONLY
+        if not args.f:
+            open_flags |= os.O_EXCL
         try:
-            manifest = reader.manifest_text()
-        except (arvados.errors.ApiError, arvados.errors.KeepReadError) as e:
-            abort(e)
-        if not args.f and os.path.exists(args.destination):
-            abort('Local file %s already exists.' % (args.destination,))
-        with open(args.destination, 'wb') as f:
-            f.write(manifest)
+            out_fd = os.open(args.destination, open_flags)
+            with os.fdopen(out_fd, 'wb') as out_file:
+                out_file.write(reader.manifest_text())
+        except (IOError, OSError) as error:
+            abort("can't write to '{}': {}".format(args.destination, error))
+        except (arvados.errors.ApiError, arvados.errors.KeepReadError) as error:
+            abort("failed to download '{}': {}".format(collection, e))
     sys.exit(0)
 
 # Scan the collection. Make an array of (stream, file, local

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list