10
10
'draft-3.dev4' , 'draft-3.dev5' , 'draft-3' , 'draft-4.dev1' ,
11
11
'draft-4.dev2' , 'draft-4.dev3' , 'v1.0.dev4' , 'v1.0' ]
12
12
DEF_VERSION = 'v1.0'
13
+ NON_NULL_CWL_TYPE = ['boolean' , 'int' , 'long' , 'float' , 'double' , 'string' , 'File' ,
14
+ 'Directory' , 'stdout' ]
13
15
CWL_TYPE = ['null' , 'boolean' , 'int' , 'long' , 'float' , 'double' , 'string' , 'File' ,
14
16
'Directory' , 'stdout' , None ]
15
17
DEF_TYPE = 'null'
16
18
17
19
20
+ def parse_param_type (param_type ):
21
+ """
22
+ Parses the parameter type as one of the required types:
23
+ :: https://www.commonwl.org/v1.0/CommandLineTool.html#CommandInputParameter
24
+
25
+
26
+ :param param_type:
27
+ :return: CWLType | CommandInputRecordSchema | CommandInputEnumSchema | CommandInputArraySchema | string |
28
+ array<CWLType | CommandInputRecordSchema | CommandInputEnumSchema | CommandInputArraySchema | string>
29
+ """
30
+
31
+ if isinstance (param_type , str ) and len (param_type ) > 0 :
32
+ # Must be CWLType
33
+ optional = param_type [- 1 ] == "?"
34
+ if optional :
35
+ _LOGGER .debug ("Detected {param_type} to be optional" .format (param_type = param_type ))
36
+ cwltype = param_type [:- 1 ] if optional else param_type
37
+ if cwltype not in CWL_TYPE :
38
+ _LOGGER .warning ("The type '{param_type}' is not a valid CWLType, expected one of: {types}"
39
+ .format (param_type = param_type , types = ", " .join (str (x ) for x in CWL_TYPE )))
40
+ _LOGGER .warning ("type is set to {}." .format (DEF_TYPE ))
41
+ return DEF_TYPE
42
+ return param_type
43
+ else :
44
+ _LOGGER .warning ("Unable to detect type of param '{param_type}" .format (param_type = param_type ))
45
+ return DEF_TYPE
46
+
47
+
18
48
class Parameter (object ):
19
49
'''
20
50
Based class for parameters (common field of Input and Output) for CommandLineTool and Workflow
@@ -40,17 +70,13 @@ def __init__(self, param_id, label=None, secondary_files=None, param_format=None
40
70
:param param_type: type of data assigned to the parameter
41
71
:type param_type: STRING corresponding to CWLType
42
72
'''
43
- if param_type not in CWL_TYPE :
44
- _LOGGER .warning ("The type {} is incorrect for the parameter." .format (param_type ))
45
- _LOGGER .warning ("type is set to {}." .format (DEF_TYPE ))
46
- param_type = DEF_TYPE
47
73
self .id = param_id
48
74
self .label = label
49
75
self .secondaryFiles = secondary_files
50
76
self .format = param_format
51
77
self .streamable = streamable
52
78
self .doc = doc
53
- self .type = param_type
79
+ self .type = parse_param_type ( param_type )
54
80
55
81
def get_dict (self ):
56
82
'''
0 commit comments