-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubflow_if_else_control_flow.json
More file actions
121 lines (121 loc) · 3.59 KB
/
Copy pathsubflow_if_else_control_flow.json
File metadata and controls
121 lines (121 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
57
58
59
60
61
62
63
64
65
66
67
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
"name": "SubFlow if/else control flow with namespaced fields",
"config": {
"_PINEAPPLE_VERSION": "0.10.12",
"pipeline_config": {
"operators": {
"my_sf::if_1": {
"type_name": "transform_by_lua",
"$metadata": {
"common_input": ["score_threshold"],
"common_output": ["_my_sf::if_1"],
"item_input": [],
"item_output": []
},
"for_branch_control": true,
"lua_script": "function evaluate() if (score_threshold > 50) then return false else return true end end",
"function_for_item": "",
"function_for_common": "evaluate"
},
"label_high_low": {
"type_name": "transform_by_lua",
"$metadata": {
"common_input": ["_my_sf::if_1", "score_threshold"],
"common_output": [],
"item_input": ["item_score"],
"item_output": ["item_label"]
},
"skip": ["_my_sf::if_1"],
"lua_script": "function label() if item_score >= score_threshold then return \"high\" else return \"low\" end end",
"function_for_item": "label",
"function_for_common": ""
},
"my_sf::else_2": {
"type_name": "transform_by_lua",
"$metadata": {
"common_input": ["_my_sf::if_1"],
"common_output": ["_my_sf::else_2"],
"item_input": [],
"item_output": []
},
"for_branch_control": true,
"lua_script": "function evaluate() if ((_G[\"_my_sf::if_1\"])) then return false else return true end end",
"function_for_item": "",
"function_for_common": "evaluate"
},
"label_default": {
"type_name": "transform_by_lua",
"$metadata": {
"common_input": ["_my_sf::else_2"],
"common_output": [],
"item_input": ["item_score"],
"item_output": ["item_label"]
},
"skip": ["_my_sf::else_2"],
"lua_script": "function fallback() return \"default\" end",
"function_for_item": "fallback",
"function_for_common": ""
}
},
"pipeline_map": {
"my_sf": {
"pipeline": [
"my_sf::if_1",
"label_high_low",
"my_sf::else_2",
"label_default"
]
}
}
},
"pipeline_group": {
"main": {
"pipeline": ["my_sf"]
}
},
"flow_contract": {
"common_input": ["score_threshold"],
"item_input": ["item_score"],
"common_output": [],
"item_output": ["item_score", "item_label"]
}
},
"cases": [
{
"name": "if branch active (score_threshold > 50): labels by score comparison",
"request": {
"common": {"score_threshold": 80},
"items": [
{"item_score": 90},
{"item_score": 70},
{"item_score": 50}
]
},
"expected": {
"common": {},
"items": [
{"item_score": 90, "item_label": "high"},
{"item_score": 70, "item_label": "low"},
{"item_score": 50, "item_label": "low"}
]
}
},
{
"name": "else branch active (score_threshold <= 50): all get default label",
"request": {
"common": {"score_threshold": 30},
"items": [
{"item_score": 100},
{"item_score": 10}
]
},
"expected": {
"common": {},
"items": [
{"item_score": 100, "item_label": "default"},
{"item_score": 10, "item_label": "default"}
]
}
}
]
}