Skip to content

Instantly share code, notes, and snippets.

@amitu
Created October 14, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitu/3d21d2a397f749436e3d to your computer and use it in GitHub Desktop.
Save amitu/3d21d2a397f749436e3d to your computer and use it in GitHub Desktop.
Luigi Example
import luigi
class SimpleTask(luigi.Task):
name = luigi.Parameter()
def output(self):
return luigi.LocalTarget(self.name)
def run(self):
_out = self.output().open('w')
_out.write("Hello %s\n" % self.name)
_out.close()
class SecondTask(luigi.Task):
def output(self):
return luigi.LocalTarget("bar.txt")
def requires(self):
return [SimpleTask(name="foo1.txt"), SimpleTask(name="foo2.txt")]
def run(self):
with self.output().open("w") as o:
for inp in self.input():
o.write(inp.open().read().upper())
if __name__ == "__main__":
luigi.run(["--local-scheduler"], main_task_cls=SecondTask)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment