4823: More fixes and cleanups.
[arvados.git] / sdk / python / arvados / __init__.py
index 060ed95d959531917749584176c5f42b8c453f66..1df64703a9577d7338f60f5dd944b1c72d854064 100644 (file)
@@ -18,10 +18,11 @@ import fcntl
 import time
 import threading
 
-from api import *
-from collection import *
+from .api import api, http_cache
+from collection import CollectionReader, CollectionWriter, ResumableCollectionWriter
 from keep import *
 from stream import *
+from arvfile import StreamFileReader
 import errors
 import util
 
@@ -82,11 +83,16 @@ class JobTask(object):
 
 class job_setup:
     @staticmethod
-    def one_task_per_input_file(if_sequence=0, and_end_task=True, input_as_path=False):
+    def one_task_per_input_file(if_sequence=0, and_end_task=True, input_as_path=False, api_client=None):
         if if_sequence != current_task()['sequence']:
             return
+
+        if not api_client:
+            api_client = api('v1')
+
         job_input = current_job()['script_parameters']['input']
-        cr = CollectionReader(job_input)
+        cr = CollectionReader(job_input, api_client=api_client)
+        cr.normalize()
         for s in cr.all_streams():
             for f in s.all_files():
                 if input_as_path:
@@ -101,9 +107,9 @@ class job_setup:
                         'input':task_input
                         }
                     }
-                api('v1').job_tasks().create(body=new_task_attrs).execute()
+                api_client.job_tasks().create(body=new_task_attrs).execute()
         if and_end_task:
-            api('v1').job_tasks().update(uuid=current_task()['uuid'],
+            api_client.job_tasks().update(uuid=current_task()['uuid'],
                                        body={'success':True}
                                        ).execute()
             exit(0)
@@ -130,5 +136,3 @@ class job_setup:
                                        body={'success':True}
                                        ).execute()
             exit(0)
-
-