Last active
November 14, 2020 05:23
-
-
Save tashrifbillah/2bca276c7a6e2d5c85e9206d6522b37e to your computer and use it in GitHub Desktop.
Simple Luigi task, useful for debugging server issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from luigi import build, Task, LocalTarget, FloatParameter | |
from luigi.util import requires | |
import numpy as np | |
class TaskA(Task): | |
a= FloatParameter(default=round(np.random.rand(),3)) | |
def run(self): | |
with open('/tmp/a.txt','w') as f: | |
f.write('a') | |
def output(self): | |
return LocalTarget('/tmp/a.txt') | |
@requires(TaskA) | |
class TaskB(Task): | |
b= FloatParameter(default=round(np.random.rand(),3)) | |
def run(self): | |
with open('/tmp/b.txt', 'w') as f: | |
f.write('b') | |
def output(self): | |
return LocalTarget('/tmp/b.txt') | |
@requires(TaskB) | |
class TaskC(Task): | |
c= FloatParameter(default=round(np.random.rand(),3)) | |
def run(self): | |
with open('/tmp/c.txt', 'w') as f: | |
f.write('c') | |
def output(self): | |
return LocalTarget('/tmp/c.txt') | |
@requires(TaskC,TaskB) | |
class TaskD(Task): | |
e= FloatParameter(default=round(np.random.rand(),3)) | |
def run(self): | |
with open('/tmp/d.txt', 'w') as f: | |
f.write('d') | |
def output(self): | |
return LocalTarget('/tmp/d.txt') | |
if __name__=='__main__': | |
build([TaskD()]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run instruction:
luigi.cfg
[core] default-scheduler-url = http://192.168.122.1:8082/