class LuigiTaskB(luigi.Task):
def run(self):
print "running task b"
with self.output().open('w') as out_file:
print >> out_file, "some text"
def output(self):
return luigi.LocalTarget("somefile")
class LuigiTaskA(luigi.Task):
task_complete = False
def requires(self):
return LuigiTaskB()
def run(self):
print "running task a"
self.task_complete = true
def complete(self):
# Make sure you return false when you want the task to run.
# And true when complete
return self.task_complete
# This will out put :
# running task b
# running task a
# And this on the second time you'll run:
# running task a
您还可以使用MockTarget,如下所示:
您可以重写整个函数。在
complete()函数查看output()函数,通过重写complete(),您可以传递任何输出并编写完成时的条件。在
请注意,如果完整函数依赖于run函数,则不能跳过它。。在
相关问题 更多 >
编程相关推荐