Merge branch 'master' into 2060-edit-tags-in-workbench
[arvados.git] / sdk / python / arvados / collection.py
index 296f9506835ea05fa6d4710749d84e105b2e0e33..ea98d00e54d3d4793fabb0dca804d3f8a68a5570 100644 (file)
@@ -18,9 +18,10 @@ import fcntl
 import time
 import threading
 
-from stream import *
 from keep import *
-import util
+from stream import *
+import config
+import errors
 
 class CollectionReader(object):
     def __init__(self, manifest_locator_or_text):
@@ -42,7 +43,14 @@ class CollectionReader(object):
         if self._streams != None:
             return
         if not self._manifest_text:
-            self._manifest_text = Keep.get(self._manifest_locator)
+            try:
+                c = arvados.api('v1').collections().get(
+                    uuid=self._manifest_locator).execute()
+                self._manifest_text = c['manifest_text']
+            except Exception as e:
+                logging.warning("API lookup failed for collection %s (%s: %s)" %
+                                (self._manifest_locator, type(e), str(e)))
+                self._manifest_text = Keep.get(self._manifest_locator)
         self._streams = []
         for stream_line in self._manifest_text.split("\n"):
             if stream_line != '':
@@ -181,7 +189,7 @@ class CollectionWriter(object):
                 (self._current_stream_length, len(self._current_stream_files)))
         else:
             if len(self._current_stream_locators) == 0:
-                self._current_stream_locators += [EMPTY_BLOCK_LOCATOR]
+                self._current_stream_locators += [config.EMPTY_BLOCK_LOCATOR]
             self._finished_streams += [[self._current_stream_name,
                                        self._current_stream_locators,
                                        self._current_stream_files]]