Repository: Duke-GCB/lando

Issue:
TypeError when parsing v2 CWLCommand
Error:
```
  File "/usr/local/lib/python3.6/site-packages/lando-0.9.3-py3.6.egg/lando/server/jobapi.py", line 482, in __init__
    self.base_command = json.loads(data.get('cwl_base_command'))
  File "/usr/local/lib/python3.6/json/__init__.py", line 348, in loads
    'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'list'
```
The problem is we are attempting to decode json and this is no longer necessary for bespin-api `v2`.
https://github.com/Duke-GCB/lando/blob/ee4148bc7934c94be4e0bcbd129ce9ee1ba8afa5/lando/server/jobapi.py#L484-L486

Discussion:

Patch:
diff --git a/lando/server/jobapi.py b/lando/server/jobapi.py
index a049cd0..fe87b69 100644
--- a/lando/server/jobapi.py
+++ b/lando/server/jobapi.py
@@ -481,9 +481,9 @@ class CWLCommand(object):
         Loads JSON-encoded CWL commands from dictionary
         :param data:
         """
-        self.base_command = json.loads(data.get('cwl_base_command'))
-        self.pre_process_command = json.loads(data.get('cwl_pre_process_command','[]'))
-        self.post_process_command = json.loads(data.get('cwl_post_process_command','[]'))
+        self.base_command = data['cwl_base_command']
+        self.pre_process_command = data.get('cwl_pre_process_command', [])
+        self.post_process_command = data.get('cwl_post_process_command', [])
 
     def __str__(self):
         return self.base_command


Test patch:
diff --git a/lando/server/tests/test_jobapi.py b/lando/server/tests/test_jobapi.py
index 4ef4c84..8fce10b 100644
--- a/lando/server/tests/test_jobapi.py
+++ b/lando/server/tests/test_jobapi.py
@@ -547,17 +547,17 @@ class CWLCommandTests(TestCase):
 
     def setUp(self):
         self.only_base_command_data = {
-            "cwl_base_command": "[\"base\", \"command\"]",
+            "cwl_base_command": ["base", "command"],
         }
         self.pre_and_post_data = {
-            "cwl_base_command": "[\"base\", \"command\"]",
-            "cwl_post_process_command": "[\"post\",\"process\",\"command\"]",
-            "cwl_pre_process_command": "[\"pre\",\"process\",\"command\"]"
+            "cwl_base_command": ["base", "command"],
+            "cwl_post_process_command": ["post", "process", "command"],
+            "cwl_pre_process_command": ["pre", "process", "command"]
         }
 
     def test_loads_base_command(self):
         command = CWLCommand(self.only_base_command_data)
-        self.assertEqual(command.base_command, ['base','command'])
+        self.assertEqual(command.base_command, ['base', 'command'])
 
     def test_requires_base_command(self):
         with self.assertRaises(Exception):
@@ -570,9 +570,9 @@ class CWLCommandTests(TestCase):
 
     def test_loads_pre_and_post(self):
         command = CWLCommand(self.pre_and_post_data)
-        self.assertEqual(command.base_command, ['base','command'])
-        self.assertEqual(command.pre_process_command, ['pre','process','command'])
-        self.assertEqual(command.post_process_command, ['post','process','command'])
+        self.assertEqual(command.base_command, ['base', 'command'])
+        self.assertEqual(command.pre_process_command, ['pre', 'process', 'command'])
+        self.assertEqual(command.post_process_command, ['post', 'process', 'command'])
 
 
 class VMSettingsTests(TestCase):