[ARVADOS] updated: 7b227c653e31449f6c23b4b8d933172bbfb2b172

Git user git at public.curoverse.com
Mon Aug 15 16:48:51 EDT 2016


Summary of changes:
 sdk/python/arvados/collection.py     |  7 ++++++-
 sdk/python/arvados/commands/put.py   |  2 +-
 sdk/python/tests/test_collections.py | 21 +++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)

       via  7b227c653e31449f6c23b4b8d933172bbfb2b172 (commit)
      from  2c640b0e791d9997ff87f4ec2b33af7781286af5 (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 7b227c653e31449f6c23b4b8d933172bbfb2b172
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Mon Aug 15 17:45:19 2016 -0300

    9463: Get Collection's manifest text including only those committed blocks, so that it can be correctly saved to the cache. Added a test for this new feature.

diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py
index 62b6526..56d8b23 100644
--- a/sdk/python/arvados/collection.py
+++ b/sdk/python/arvados/collection.py
@@ -922,7 +922,7 @@ class RichCollectionBase(CollectionBase):
         return self._get_manifest_text(stream_name, strip, normalize)
 
     @synchronized
-    def _get_manifest_text(self, stream_name, strip, normalize):
+    def _get_manifest_text(self, stream_name, strip, normalize, only_committed=False):
         """Get the manifest text for this collection, sub collections and files.
 
         :stream_name:
@@ -938,6 +938,9 @@ class RichCollectionBase(CollectionBase):
           is not modified, return the original manifest text even if it is not
           in normalized form.
 
+        :only_committed:
+          If True, only include blocks that were already committed to Keep.
+
         """
 
         if not self.committed() or self._manifest_text is None or normalize:
@@ -951,6 +954,8 @@ class RichCollectionBase(CollectionBase):
                 for segment in arvfile.segments():
                     loc = segment.locator
                     if arvfile.parent._my_block_manager().is_bufferblock(loc):
+                        if only_committed:
+                            continue
                         loc = arvfile.parent._my_block_manager().get_bufferblock(loc).locator()
                     if strip:
                         loc = KeepLocator(loc).stripped()
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 43e3813..4034173 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -389,7 +389,7 @@ class ArvPutUploadJob(object):
             if self.resume:
                 with self._state_lock:
                     # Get the manifest text without comitting pending blocks
-                    self._state['manifest'] = self._my_collection()._get_manifest_text(".", strip=False, normalize=False)
+                    self._state['manifest'] = self._my_collection()._get_manifest_text(".", strip=False, normalize=False, only_committed=True)
         if self.resume:
             self._save_state()
         # Call the reporter, if any
diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py
index 41c8c01..668f2e2 100644
--- a/sdk/python/tests/test_collections.py
+++ b/sdk/python/tests/test_collections.py
@@ -1082,6 +1082,27 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         self.assertEqual(c1["count1.txt"].size(), 0)
 
 
+class NewCollectionTestCaseWithServers(run_test_server.TestCaseWithServers):
+    def test_get_manifest_text_only_committed(self):
+        c = Collection()
+        with c.open("count.txt", "w") as f:
+            f.write("0123456789")
+            # Block not written to keep yet
+            self.assertNotEqual(
+                c._get_manifest_text(".",
+                                     strip=False,
+                                     normalize=False,
+                                     only_committed=True),
+                ". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n")
+        # And now with the file closed...
+        self.assertEqual(
+            c._get_manifest_text(".",
+                                 strip=False,
+                                 normalize=False,
+                                 only_committed=True),
+            ". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n")
+
+
 class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers):
     MAIN_SERVER = {}
     KEEP_SERVER = {}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list