13627: a-c-r migration to cwltool loading/runtimeContext API
[arvados.git] / sdk / cwl / arvados_cwl / crunch_script.py
index 12d74a05c6aa855df8086d216f1e706df82ed680..94e9c8fc84abcd2511935d63b7c413e77da38948 100644 (file)
@@ -27,6 +27,7 @@ from cwltool.process import shortname
 from cwltool.pathmapper import adjustFileObjs, adjustDirObjs, normalizeFilesDirs
 from cwltool.load_tool import load_tool
 from cwltool.errors import WorkflowException
+from cwltool.context import RuntimeContext
 
 from .fsaccess import CollectionFetcher, CollectionFsAccess
 
@@ -97,7 +98,8 @@ def run():
             debug = job_order_object["arv:debug"]
             del job_order_object["arv:debug"]
 
-        runner = arvados_cwl.ArvCwlRunner(api_client=arvados.api('v1', model=OrderedJsonModel()),
+        runner = arvados_cwl.ArvCwlRunner(api_client=arvados.safeapi.ThreadSafeApiCache(
+            api_params={"model": OrderedJsonModel()}, keep_params={"num_retries": 4}),
                                           output_name=output_name, output_tags=output_tags)
 
         make_fs_access = functools.partial(CollectionFsAccess,
@@ -114,7 +116,7 @@ def run():
             logging.getLogger('arvados').setLevel(logging.DEBUG)
             logging.getLogger("cwltool").setLevel(logging.DEBUG)
 
-        args = argparse.Namespace()
+        args = RuntimeContext()
         args.project_uuid = arvados.current_job()["owner_uuid"]
         args.enable_reuse = enable_reuse
         args.on_error = on_error
@@ -128,8 +130,12 @@ def run():
         args.make_fs_access = make_fs_access
         args.trash_intermediate = False
         args.intermediate_output_ttl = 0
+        args.priority = arvados_cwl.DEFAULT_PRIORITY
+        args.do_validate = True
+        args.disable_js_validation = False
+        args.tmp_outdir_prefix = "tmp"
 
-        runner.arv_executor(t, job_order_object, **vars(args))
+        runner.arv_executor(t, job_order_object, args)
     except Exception as e:
         if isinstance(e, WorkflowException):
             logging.info("Workflow error %s", e)