Created
May 20, 2015 10:38
-
-
Save vicenteg/7cf285cd02a654dbc1e9 to your computer and use it in GitHub Desktop.
small luigi example
This file contains hidden or 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
mport os | |
import luigi | |
class Foo(luigi.Task): | |
def run(self): | |
print "Running Foo" | |
def requires(self): | |
print ">>>>>> Foo.requires()" | |
for i in xrange(10): | |
yield Bar(i) | |
class Bar(luigi.Task): | |
num = luigi.IntParameter() | |
def run(self): | |
print ">>>>>> Bar.run(%d)" % self.num | |
self.output().open('w').close() | |
def output(self): | |
""" | |
Returns the target output for this task. | |
:return: the target output for this task. | |
:rtype: object (:py:class:`~luigi.target.Target`) | |
""" | |
print ">>>>>> Bar.output()" | |
return luigi.LocalTarget('/tmp/bar/%d' % self.num) | |
if __name__ == "__main__": | |
luigi.run(main_task_cls=Foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment