-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjugfile.py
More file actions
34 lines (25 loc) · 650 Bytes
/
jugfile.py
File metadata and controls
34 lines (25 loc) · 650 Bytes
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
# This code is supporting material for the book
# Building Machine Learning Systems with Python
# by Willi Richert and Luis Pedro Coelho
# published by PACKT Publishing
#
# It is made available under the MIT License
from jug import TaskGenerator
from time import sleep
@TaskGenerator
def double(x):
sleep(4)
return 2 * x
@TaskGenerator
def add(a, b):
return a + b
@TaskGenerator
def print_final_result(oname, value):
with open(oname, 'w') as output:
output.write("Final result: {}\n".format(value))
input = 2
y = double(input)
z = double(y)
y2 = double(7)
z2 = double(y2)
print_final_result('output.txt', add(z, z2))