1+ """
2+
3+ Basic Data Types
4+ ^^^^^^^^^^^^^^^^^
5+
6+ Each variable can be an input or an output. The basic data types are:
7+
8+ * Inputs:
9+
10+ * CWLFilePathInput
11+
12+ * CWLBooleanInput
13+
14+ * CWLStringInput
15+
16+ * CWLIntInput
17+
18+ * Outputs:
19+
20+ * CWLFilePathOutput
21+
22+ * CWLDumpableFile
23+
24+ * CWLDumpableBinaryFile
25+
26+
27+ Complex Dumpables Types
28+ ^^^^^^^^^^^^^^^^^^^^^^^^
29+
30+ Dumpables are variables which are able to be written to a file, but the jupyter notebook developer
31+ does not want to write it, for example to avoid the IO overhead. To bypass that, you can use
32+ Dumpables annotation. See :func:`~iotypes.CWLDumpable.dump` for more details.
33+
34+ """
135from typing import Callable
236
337
@@ -6,18 +40,50 @@ class _CWLInput:
640
741
842class CWLFilePathInput (str , _CWLInput ):
43+ """Use that hint to annotate that a variable is a string-path input. You can use the typing annotation
44+ as a string by importing it. At the generated script a command line argument with the name of the variable
45+ will be created and the assignment of value will be generalised.
46+
47+ >>> dataset1: CWLFilePathInput = './data/data.csv'
48+ >>> dataset2: 'CWLFilePathInput' = './data/data.csv'
49+
50+ """
951 pass
1052
1153
1254class CWLBooleanInput (_CWLInput ):
55+ """Use that hint to annotate that a variable is a boolean input. You can use the typing annotation
56+ as a string by importing it. At the generated script a command line argument with the name of the variable
57+ will be created and the assignment of value will be generalised.
58+
59+ >>> dataset1: CWLBooleanInput = True
60+ >>> dataset2: 'CWLBooleanInput' = False
61+
62+ """
1363 pass
1464
1565
1666class CWLStringInput (str , _CWLInput ):
67+ """Use that hint to annotate that a variable is a string input. You can use the typing annotation
68+ as a string by importing it. At the generated script a command line argument with the name of the variable
69+ will be created and the assignment of value will be generalised.
70+
71+ >>> dataset1: CWLBooleanInput = 'this is a message input'
72+ >>> dataset2: 'CWLBooleanInput' = 'yet another message input'
73+
74+ """
1775 pass
1876
1977
2078class CWLIntInput (_CWLInput ):
79+ """Use that hint to annotate that a variable is a integer input. You can use the typing annotation
80+ as a string by importing it. At the generated script a command line argument with the name of the variable
81+ will be created and the assignment of value will be generalised.
82+
83+ >>> dataset1: CWLBooleanInput = 1
84+ >>> dataset2: 'CWLBooleanInput' = 2
85+
86+ """
2187 pass
2288
2389
@@ -26,19 +92,69 @@ class _CWLOutput:
2692
2793
2894class CWLFilePathOutput (str , _CWLOutput ):
95+ """Use that hint to annotate that a variable is a string-path to an output file. You can use the typing annotation
96+ as a string by importing it. The generated file will be mapped as a CWL output.
97+
98+ >>> filename: CWLBooleanInput = 'data.csv'
99+
100+ """
29101 pass
30102
31103
32104class CWLDumpable (_CWLOutput ):
105+ """Use that class to define custom Dumpables variables."""
33106
34107 @classmethod
35- def dump (cls , dumper : Callable , * args , ** kwargs ):
108+ def dump (cls , dumper : Callable , filename , * args , ** kwargs ):
109+ """
110+ Set the function to be used to dump the variable to a file.
111+
112+ >>> import pandas
113+ >>> d: CWLDumpable.dump(d.to_csv, "dumpable.csv", sep="\\ t", index=False) = pandas.DataFrame(
114+ ... [[1,2,3], [4,5,6], [7,8,9]]
115+ ... )
116+
117+ In that example the converter will add at the end of the script the following line:
118+ >>> d.to_csv("dumpable.csv", sep="\\ t", index=False)
119+
120+ :param dumper: The function that has to be called to write the variable to a file.
121+ :param filename: The name of the generated file. That string must be the first argument
122+ in the dumper function. That file will also be mapped as an output in
123+ the CWL file.
124+ :param args: Any positional arguments you want to pass to dumper after the filename
125+ :param kwargs: Any keyword arguments you want to pass to dumper
126+ """
36127 return _CWLOutput
37128
38129
39130class CWLDumpableFile (CWLDumpable ):
131+ """Use that annotation to define that a variable should be dumped to a text file. For example for the annotation:
132+
133+ >>> data: CWLDumpableFile = "this is text data"
134+
135+
136+ the converter will append at the end of the script the following lines:
137+
138+
139+ >>> with open('data', 'w') as f:
140+ ... f.write(data)
141+
142+
143+ and at the CWL, the data, will be mapped as a output.
144+ """
40145 pass
41146
42147
43148class CWLDumpableBinaryFile (CWLDumpable ):
149+ """Use that annotation to define that a variable should be dumped to a binary file. For example for the annotation:
150+
151+ >>> data: CWLDumpableBinaryFile = b"this is text data"
152+
153+ the converter will append at the end of the script the following lines:
154+
155+ >>> with open('data', 'wb') as f:
156+ ... f.write(data)
157+
158+ and at the CWL, the data, will be mapped as a output.
159+ """
44160 pass
0 commit comments