Created
October 14, 2015 13:18
-
-
Save amitu/3d21d2a397f749436e3d to your computer and use it in GitHub Desktop.
Luigi Example
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
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