10081: Rename cwl.input.json to cwl.input.yml, fix test.
[arvados.git] / sdk / cwl / arvados_cwl / arvjob.py
index 4ba19a6babd33b3a13d0ded112e34fd9f1557091..78bca6e0e1ea9ffc49d6b35287556e98284658f5 100644 (file)
@@ -1,6 +1,7 @@
 import logging
 import re
 import copy
+import json
 
 from cwltool.process import get_feature, shortname
 from cwltool.errors import WorkflowException
@@ -185,9 +186,11 @@ class ArvadosJob(object):
             except WorkflowException as e:
                 logger.error("Error while collecting job outputs:\n%s", e, exc_info=(e if self.arvrunner.debug else False))
                 processStatus = "permanentFail"
+                outputs = None
             except Exception as e:
                 logger.exception("Got unknown exception while collecting job outputs:")
                 processStatus = "permanentFail"
+                outputs = None
 
             self.output_callback(outputs, processStatus)
         finally:
@@ -207,7 +210,7 @@ class RunnerJob(Runner):
 
         workflowmapper = super(RunnerJob, self).arvados_job_spec(dry_run=dry_run, pull_image=pull_image, **kwargs)
 
-        self.job_order["cwl:tool"] = workflowmapper.mapper(self.tool.tool["id"])[1]
+        self.job_order["cwl:tool"] = workflowmapper.mapper(self.tool.tool["id"]).target[5:]
         return {
             "script": "cwl-runner",
             "script_version": "master",
@@ -250,6 +253,7 @@ class RunnerTemplate(object):
     type_to_dataclass = {
         'boolean': 'boolean',
         'File': 'File',
+        'Directory': 'Collection',
         'float': 'number',
         'int': 'number',
         'string': 'text',
@@ -316,8 +320,8 @@ class RunnerTemplate(object):
                 pass
             elif not isinstance(value, dict):
                 param['value'] = value
-            elif param.get('dataclass') == 'File' and value.get('location'):
-                param['value'] = value['location']
+            elif param.get('dataclass') in ('File', 'Collection') and value.get('location'):
+                param['value'] = value['location'][5:]
 
             spec['script_parameters'][param_id] = param
         spec['script_parameters']['cwl:tool'] = job_params['cwl:tool']