Skip to content

Instantly share code, notes, and snippets.

@vicenteg
Created May 20, 2015 10:38
Show Gist options
  • Save vicenteg/7cf285cd02a654dbc1e9 to your computer and use it in GitHub Desktop.
Save vicenteg/7cf285cd02a654dbc1e9 to your computer and use it in GitHub Desktop.
small luigi example
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