Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ipython2cwl/cwltoolextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import yaml
from nbformat.notebooknode import NotebookNode # type: ignore

from .iotypes import CWLFilePathInput, CWLBooleanInput, CWLIntInput, CWLStringInput, CWLFilePathOutput, \
CWLDumpableFile, CWLDumpableBinaryFile, CWLDumpable, CWLPNGPlot, CWLPNGFigure
from .iotypes import CWLFilePathInput, CWLBooleanInput, CWLIntInput, CWLFloatInput, CWLStringInput, \
CWLFilePathOutput, CWLDumpableFile, CWLDumpableBinaryFile, CWLDumpable, CWLPNGPlot, CWLPNGFigure
from .requirements_manager import RequirementsManager

with open(os.sep.join([os.path.abspath(os.path.dirname(__file__)), 'templates', 'template.dockerfile'])) as f:
Expand Down Expand Up @@ -46,6 +46,10 @@ class AnnotatedVariablesExtractor(ast.NodeTransformer):
'int',
'int',
),
(CWLFloatInput.__name__,): (
'float',
'float',
),
(CWLStringInput.__name__,): (
'string',
'str',
Expand Down
13 changes: 13 additions & 0 deletions ipython2cwl/iotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* CWLIntInput

* CWLFloatInput

* Outputs:

* CWLFilePathOutput
Expand Down Expand Up @@ -86,6 +88,17 @@ class CWLIntInput(_CWLInput):
"""
pass

class CWLFloatInput(_CWLInput):
"""Use that hint to annotate that a variable is a float input. You can use the typing annotation
as a string by importing it. At the generated script a command line argument with the name of the variable
will be created and the assignment of value will be generalised.

>>> dataset1: CWLFloatInput = 1.0
>>> dataset2: 'CWLFloatInput' = 2.0

"""
pass


class _CWLOutput:
pass
Expand Down
13 changes: 10 additions & 3 deletions tests/test_cwltoolextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def test_AnnotatedIPython2CWLToolConverter_cwl_command_line_tool(self):
"import csv",
"input_filename: CWLFilePathInput = 'data.csv'",
"flag: CWLBooleanInput = true",
"num: CWLIntInput = 1",
"num_int: CWLIntInput = 1",
"num_float: CWLFloatInput = 1.0",
"msg: CWLStringInput = 'hello world'",
"with open(input_filename) as f:",
"\tcsv_reader = csv.reader(f)",
Expand Down Expand Up @@ -50,10 +51,16 @@ def test_AnnotatedIPython2CWLToolConverter_cwl_command_line_tool(self):
'prefix': '--flag'
}
},
'num': {
'num_int': {
'type': 'int',
'inputBinding': {
'prefix': '--num'
'prefix': '--num_int'
}
},
'num_float': {
'type': 'float',
'inputBinding': {
'prefix': '--num_float'
}
},
'msg': {
Expand Down