Last active
August 26, 2016 23:06
-
-
Save gouthambs/873ebce21062914f038d to your computer and use it in GitHub Desktop.
Minimal 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
# Minimal Luigi Example - Gouthaman Balaraman | |
# http://gouthamanbalaraman.com/blog/building-luigi-task-pipeline.html | |
import luigi | |
class SimpleTask(luigi.Task): | |
""" | |
This simple task prints Hello World! | |
""" | |
def output(self): | |
return MockFile("SimpleTask", mirror_on_stderr=True) | |
def run(self): | |
_out = self.output().open('w') | |
_out.write(u"Hello World!\n") | |
_out.close() | |
if __name__ == '__main__': | |
from luigi.mock import MockFile # import this here for compatibility with Windows | |
# if you are running windows, you wouldn need --lock-pid-dir argument; modified run would look like | |
# luigi.run(["--lock-pid-dir", "D:\\temp\\", "--local-scheduler"], main_task_cls=SimpleTask) | |
luigi.run(["--local-scheduler"], main_task_cls=SimpleTask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment