-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtask_interface_example.py
65 lines (46 loc) · 1.15 KB
/
task_interface_example.py
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
# Define 4 tasks that run in sequence
def task1():
"""
Initial task that gathers data, therefore does not need any other arguments.
"""
# Gather data from IoT sensor
pass
# Return success and arg for next task
return True, 'arg1'
def task2(arg1):
"""
Second task that depends on the output of the first task.
"""
# Do computation
pass
# Return success and multiple args for next task
return True, ('arg1', 'arg2', 'arg3')
def task3(arg1, arg2, arg3):
"""
Third task that depends on the output of the second task.
Performs some basic filtering on the data.
"""
# Do computation
pass
# Do filter
if arg1 == arg2:
# Return failure, next task will not be run
return False
# Otherwise return success, args for next task
return True, 'arg4'
def task4(arg4):
"""
Last task that depends on the output of the third task.
Does not return any results, as this is the last task.
"""
# Report results
pass
# End of tasks
return False
# Export sequential ordering of tasks
tasks = [
task1,
task2,
task3,
task4
]