[ARVADOS] updated: 5771118026ed8906350f416ac1e482bf810978fa

Git user git at public.curoverse.com
Mon Apr 25 14:36:01 EDT 2016


Summary of changes:
 sdk/cwl/arvados_cwl/__init__.py | 37 ++++++++++++++++++++++++++++++++++++-
 sdk/cwl/tests/test_submit.py    | 14 ++++++++++----
 2 files changed, 46 insertions(+), 5 deletions(-)

       via  5771118026ed8906350f416ac1e482bf810978fa (commit)
      from  82f2fc3b04aaa31a254e6f97da7bb2befb5cad83 (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 5771118026ed8906350f416ac1e482bf810978fa
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Apr 25 14:35:52 2016 -0400

    8653: Translate pipeline parameter specs from CWL to Arvados.

diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py
index d714a69..c01bb46 100644
--- a/sdk/cwl/arvados_cwl/__init__.py
+++ b/sdk/cwl/arvados_cwl/__init__.py
@@ -418,6 +418,13 @@ class RunnerJob(object):
 class RunnerTemplate(object):
     """An Arvados pipeline template that invokes a CWL workflow."""
 
+    class_to_dataclass = {
+        'File': 'File',
+        'string': 'text',
+        'int': 'number',
+        'float': 'number',
+    }
+
     def __init__(self, runner, tool, job_order, enable_reuse):
         self.runner = runner
         self.job = RunnerJob(
@@ -426,8 +433,36 @@ class RunnerTemplate(object):
             job_order=job_order,
             enable_reuse=enable_reuse)
 
+    def pipeline_component_spec(self):
+        """Return a component that Workbench and a-r-p-i will understand.
+
+        Specifically, translate CWL input specs to Arvados pipeline
+        format, like {"dataclass":"File","value":"xyz"}.
+        """
+        spec = self.job.arvados_job_spec()
+        for param in spec['script_parameters'].itervalues():
+            if not isinstance(param, dict):
+                continue
+            classes = param['class']
+            if not isinstance(classes, list):
+                classes = [classes]
+            param['required'] = None not in classes
+            non_null_classes = set(classes) - set([None])
+            if len(non_null_classes) == 1:
+                input_class = [c for c in non_null_classes][0]
+                dataclass = self.class_to_dataclass.get(input_class)
+                if dataclass:
+                    param['dataclass'] = dataclass
+                    del param['class']
+            # Note: If we can't figure out a single appropriate
+            # dataclass, we leave the "class" attribute intact.
+            if dataclass == 'File' and param.get('path'):
+                param['value'] = param['path']
+                del param['path']
+        return spec
+
     def save(self):
-        job_spec = self.job.arvados_job_spec()
+        job_spec = self.pipeline_component_spec()
         response = self.runner.api.pipeline_templates().create(body={
             "components": {
                 self.job.name: job_spec,
diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py
index 3a5c38f..d663f46 100644
--- a/sdk/cwl/tests/test_submit.py
+++ b/sdk/cwl/tests/test_submit.py
@@ -141,7 +141,12 @@ class TestCreateTemplate(unittest.TestCase):
         stubs.api.pipeline_instances().create.refute_called()
         stubs.api.jobs().create.refute_called()
 
-        expect_component = stubs.expect_job_spec
+        expect_component = copy.deepcopy(stubs.expect_job_spec)
+        expect_component['script_parameters']['x'] = {
+            'dataclass': 'File',
+            'value': '99999999999999999999999999999992+99/blorp.txt',
+            'required': True,
+        }
         expect_template = {
             "components": {
                 "submit_wf.cwl": expect_component,
@@ -150,7 +155,7 @@ class TestCreateTemplate(unittest.TestCase):
             "owner_uuid": project_uuid,
         }
         stubs.api.pipeline_templates().create.assert_called_with(
-            body=expect_template)
+            body=JsonDiffMatcher(expect_template))
 
         self.assertEqual(capture_stdout.getvalue(),
                          json.dumps(stubs.expect_pipeline_template_uuid))
@@ -223,9 +228,10 @@ class TestCreateTemplate(unittest.TestCase):
                         'wf/inputs_test.cwl',
                         '#optionalFloatInput': None,
                         '#fileInput': {
-                            'path':
+                            'value':
                             '99999999999999999999999999999992+99/blorp.txt',
-                            'class': 'File',
+                            'dataclass': 'File',
+                            'required': True,
                         },
                         '#floatInput': 1.234,
                         '#boolInput': True,

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list