__init__.py 11.4 KB
Newer Older
Frédéric Escudié's avatar
Frédéric Escudié committed
1
#
Jerome Mariette's avatar
Jerome Mariette committed
2
# Copyright (C) 2015 INRA
Frédéric Escudié's avatar
Frédéric Escudié committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

Frédéric Escudié's avatar
Frédéric Escudié committed
18
19
20
import os
import sys

Frédéric Escudié's avatar
Frédéric Escudié committed
21
22
23
from jflow.workflow import Workflow
from jflow.parameter import InputFileList, InputFile

Frédéric Escudié's avatar
Frédéric Escudié committed
24

Frédéric Escudié's avatar
Frédéric Escudié committed
25
26
27
28
29
class Test (Workflow):
    def get_description(self):
        return "use for test jflow core modifications"

    def define_parameters(self, parameters_section=None):
Frédéric Escudié's avatar
Frédéric Escudié committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        self.add_parameter("test_E1", "float null.", type="float", group="test group")
        self.add_parameter("test_E2", "float default 1.", type="float", default=1, group="test group")
        self.add_parameter("test_E3", "int default 2.", type=int, default=2, group="test group")
        self.add_parameter("test_E4", "int null.", type=int, group="test group")
        self.add_parameter("test_E5", "date default str 20/08/2014.", type="date", default="20/08/2014", group="test group")
        self.add_parameter("test_E6", "date default null.", type="date", group="test group")
        self.add_parameter("test_E7", "string default str None.", default="None", group="test group")
        self.add_parameter("test_E8", "string null.", group="test group")
        self.add_parameter("test_E9", "bool default True.", type="bool", default=True, group="test group")
        self.add_parameter("test_E10", "bool default false.", type="bool", default=False, group="test group")
        self.add_parameter("test_E11", "bool default null.", type="bool", group="test group")
        self.add_input_file("test_E12", "InputFile default null.", group="test group")
        self.add_input_file("test_E13", "InputFile default application.properties.", default="application.properties", group="test group")
#         self.add_multiple_parameter_list("multi1", "Multiple.")
#         self.add_parameter("test_A1", "Multiple float null.", add_to="multi1", type="float")
#         self.add_parameter("test_A2", "Multiple float default 1.", add_to="multi1", type="float", default=1)
#         self.add_parameter("test_A3", "Multiple int default 2.", add_to="multi1", type=int, default=2)
#         self.add_parameter("test_A4", "Multiple int null.", add_to="multi1", type=int)
#         self.add_parameter("test_A5", "Multiple date default str '20/08/2014'.", add_to="multi1", type="date", default="20/08/2014")
#         self.add_parameter("test_A6", "date default null.", add_to="multi1", type="date")
#         self.add_parameter("test_A7", "Multiple string default str 'None'.", add_to="multi1", default="None")
#         self.add_parameter("test_A8", "Multiple string null.", add_to="multi1")
#         self.add_parameter("test_A9", "Multiple bool default True.", add_to="multi1", type="bool", default=True)
#         self.add_parameter("test_A10", "Multiple bool default 3.", add_to="multi1", type="bool", default=3)
#         self.add_parameter("test_A11", "Multiple bool default null.", add_to="multi1", type="bool")
#         self.add_input_file("test_A12", "Multiple InputFile default null.", add_to="multi1")
#         self.add_input_file("test_A13", "Multiple InputFile default application.properties.", add_to="multi1", default="application.properties")
Frédéric Escudié's avatar
Frédéric Escudié committed
57
58
59
60
61
62
63
64
65
66
67
        self.add_parameter("test_B1", "float null.", type="float")
        self.add_parameter("test_B2", "float default 1.", type="float", default=1)
        self.add_parameter("test_B3", "int default 2.", type=int, default=2)
        self.add_parameter("test_B4", "int null.", type=int)
        self.add_parameter("test_B5", "date default str 20/08/2014.", type="date", default="20/08/2014")
        self.add_parameter("test_B6", "date default null.", type="date")
        self.add_parameter("test_B7", "string default str None.", default="None")
        self.add_parameter("test_B8", "string null.")
        self.add_parameter("test_B9", "bool default True.", type="bool", default=True)
        self.add_parameter("test_B10", "bool default false.", type="bool", default=False)
        self.add_parameter("test_B11", "bool default null.", type="bool")
Frédéric Escudié's avatar
Frédéric Escudié committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
        self.add_input_file("test_B12", "InputFile default null.")
        self.add_input_file("test_B13", "InputFile default application.properties.", default="application.properties")
        self.add_input_file_list("test_B16", "InputFileList default null.")
#         self.add_multiple_parameter_list("multi2", "Multiple list required.", required=True)
#         self.add_parameter("valid", "Multiple required.", add_to="multi2", default="ok")
#         self.add_parameter("test_C1", "Multiple float null.", add_to="multi2", type="float")
#         self.add_parameter("test_C2", "Multiple float default 1.", add_to="multi2", type="float", default=1)
#         self.add_parameter("test_C3", "Multiple int default 2.", add_to="multi2", type=int, default=2)
#         self.add_parameter("test_C4", "Multiple int null.", add_to="multi2", type=int)
#         self.add_parameter("test_C5", "Multiple date default str '20/08/2014'.", add_to="multi2", type="date", default="20/08/2014")
#         self.add_parameter("test_C6", "date default null.", add_to="multi2", type="date")
#         self.add_parameter("test_C7", "Multiple string default str 'None'.", add_to="multi2", default="None")
#         self.add_parameter("test_C8", "Multiple string null.", add_to="multi2")
#         self.add_parameter("test_C9", "Multiple bool default True.", add_to="multi2", type="bool", default=True)
#         self.add_parameter("test_C10", "Multiple bool default 3.", add_to="multi2", type="bool", default=3)
#         self.add_parameter("test_C11", "Multiple bool default null.", add_to="multi2", type="bool")
#         self.add_input_file("test_C12", "Multiple InputFile default null.", add_to="multi2")
#         self.add_input_file("test_C13", "Multiple InputFile default application.properties.", add_to="multi2", default="application.properties")##### Pb localfile and urlfile
#         self.add_parameter_list("test_C14", "Multiple ParameterList [1, 2, 3]", add_to="multi2", default=[1, 2, 3])
#         self.add_parameter_list("test_C15", "Multiple ParameterList default null", add_to="multi2")
#         self.add_input_file_list("test_C16", "InputFileList default null.", add_to="multi2")
        self.add_multiple_parameter("multi3", "Multiple required.")
        self.add_parameter("valid", "Multiple required.", add_to="multi3", default="ok")
        self.add_parameter("test_D1", "Multiple float null.", add_to="multi3", type="float")
        self.add_parameter("test_D2", "Multiple float default 1.", add_to="multi3", type="float", default=1)
        self.add_parameter("test_D3", "Multiple int default 2.", add_to="multi3", type=int, default=2)
        self.add_parameter("test_D4", "Multiple int null.", add_to="multi3", type=int)
        self.add_parameter("test_D5", "Multiple date default str '20/08/2014'.", add_to="multi3", type="date", default="20/08/2014")
        self.add_parameter("test_D6", "date default null.", add_to="multi3", type="date")
        self.add_parameter("test_D7", "Multiple string default str 'None'.", add_to="multi3", default="None")
        self.add_parameter("test_D8", "Multiple string null.", add_to="multi3")
        self.add_parameter("test_D9", "Multiple bool default True.", add_to="multi3", type="bool", default=True)
        self.add_parameter("test_D10", "Multiple bool default 3.", add_to="multi3", type="bool", default=3)
        self.add_parameter("test_D11", "Multiple bool default null.", add_to="multi3", type="bool")
        self.add_input_file("test_D12", "Multiple InputFile default null.", add_to="multi3")
        self.add_input_file("test_D13", "Multiple InputFile default application.properties.", add_to="multi3", default="application.properties")##### Pb localfile and urlfile
        self.add_parameter_list("test_D14", "Multiple ParameterList [1, 2, 3]", add_to="multi3", default=[1, 2, 3])
        self.add_parameter_list("test_D15", "Multiple ParameterList default null", add_to="multi3")
        self.add_input_file_list("test_D16", "InputFileList default null.", add_to="multi3")

Frédéric Escudié's avatar
Frédéric Escudié committed
108
109

    def process(self):
Frédéric Escudié's avatar
Frédéric Escudié committed
110
        sys.stdout = open(os.path.join(self.directory, "wf_stdout"), 'w')
111
        print ("###################### Workflow ############################")
Frédéric Escudié's avatar
Frédéric Escudié committed
112
113
        for attr in self.params_order:
            value = getattr(self, attr)
114
115
116
117
118
            print (attr)
            print (value)
            print(("class   : " + value.__class__.__name__))
            print(("== None : " + str(value == None)))
            print ("")
Frédéric Escudié's avatar
Frédéric Escudié committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
        sys.stdout.close()
#         test_parameters = self.add_component("TestComponentParameters", [
#                                                                          self.test_B1,
#                                                                          self.test_B2,
#                                                                          self.test_B3,
#                                                                          self.test_B4,
#                                                                          self.test_B5,
#                                                                          self.test_B6,
#                                                                          self.test_B7,
#                                                                          self.test_B8,
#                                                                          self.test_B9,
#                                                                          self.test_B10,
#                                                                          self.test_B11,
#                                                                          self.test_B12,
#                                                                          self.test_B13,
#                                                                          self.multi2[0]["test_C1"],
#                                                                          self.multi2[0]["test_C2"],
#                                                                          self.multi2[0]["test_C3"],
#                                                                          self.multi2[0]["test_C4"],
#                                                                          self.multi2[0]["test_C5"],
#                                                                          self.multi2[0]["test_C6"],
#                                                                          self.multi2[0]["test_C7"],
#                                                                          self.multi2[0]["test_C8"],
#                                                                          self.multi2[0]["test_C9"],
#                                                                          self.multi2[0]["test_C10"],
#                                                                          self.multi2[0]["test_C11"],
#                                                                          self.multi2[0]["test_C12"],
#                                                                          self.multi2[0]["test_C13"]
#                                                                          ])