PMCC-BioinformaticsCore / janis-core

Core python modules for Janis Pipeline workflow assistant
GNU General Public License v3.0
4 stars 9 forks source link

PythonTool broken? #23

Closed drtconway closed 4 years ago

drtconway commented 4 years ago

Hi Janis,

I just created the following tool for testing some changes:

from typing import Dict, Optional, List, Any
from janis_core import PythonTool, TOutput, Array, File, String

class Lines(PythonTool):
    @staticmethod
    def code_block(in_file: File) -> Dict[str, Any]:
        with open(in_file) as f:
            return {"out": [l.strip() for l in f]}

    def outputs(self) -> List[TOutput]:
        return [
            TOutput("out", Array(String))
        ]

    def id(self) -> str:
        return "lines"

    def version(self):
        return "v0.1.0"
root@6bc48a648512:/janis# cat lines.py 
from typing import Dict, Optional, List, Any
from janis_core import PythonTool, TOutput, Array, File, String

class Lines(PythonTool):
    @staticmethod
    def code_block(in_file: File) -> Dict[str, Any]:
        with open(in_file) as f:
            return {"out": [l.strip() for l in f]}

    def outputs(self) -> List[TOutput]:
        return [
            TOutput("out", Array(String))
        ]

    def id(self) -> str:
        return "lines"

    def version(self):
        return "v0.1.0"

When I run it, I get the following error:

root@6bc48a648512:/janis# janis run -o foo lines.py --in_file test-input.sam 
2020-05-22T04:33:27 [INFO]: Starting task with id = 'c4a162'
c4a162
2020-05-22T04:33:27 [WARN]: Could not find a cromwell process to end, SKIPPING
Traceback (most recent call last):
  File "/usr/local/bin/janis", line 11, in <module>
    load_entry_point('janis-pipelines.runner==0.9.16', 'console_scripts', 'janis')()
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/cli.py", line 152, in process_args
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/cli.py", line 764, in do_run
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/main.py", line 488, in fromjanis
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/main.py", line 458, in fromjanis
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/management/configmanager.py", line 189, in start_task
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/management/workflowmanager.py", line 189, in from_janis
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.runner-0.9.16-py3.8.egg/janis_assistant/management/workflowmanager.py", line 624, in prepare_and_output_workflow_to_evaluate_if_required
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.core-0.9.16-py3.8.egg/janis_core/translations/translationbase.py", line 81, in translate
    tr_tool = self.translate_tool_internal(
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.core-0.9.16-py3.8.egg/janis_core/translations/wdl.py", line 364, in translate_tool_internal
    ins: List[wdl.Input] = cls.translate_tool_inputs(inputs)
  File "/usr/local/lib/python3.8/dist-packages/janis_pipelines.core-0.9.16-py3.8.egg/janis_core/translations/wdl.py", line 269, in translate_tool_inputs
    wd = i.input_type.wdl(has_default=i.default is not None)
AttributeError: 'TInput' object has no attribute 'input_type'
root@6bc48a648512:/janis# 

I used janis translate lines.py wdl and extracted the here-document python script which runs fine from the command line.

FYI:

root@6bc48a648512:/janis# janis --version
--------------------  -------
janis-core            v0.9.16
janis-assistant       v0.9.16
janis-unix            v0.9.0
janis-bioinformatics  v0.9.12
janis-pipelines       v0.9.5
janis-templates       v0.9.5
--------------------  -------
root@6bc48a648512:/janis# 

(It might be handy to include the git commit hash, or something for greater precision during development.)

illusional commented 4 years ago

Thanks @drtconway, confirmed and fixed in: https://github.com/PMCC-BioinformaticsCore/janis-core/commit/6f7272aef8f59a275441cf3ce9841d12c434afa5