Skip to content

Instantly share code, notes, and snippets.

@gouthambs
Last active August 26, 2016 23:06
Show Gist options
  • Save gouthambs/873ebce21062914f038d to your computer and use it in GitHub Desktop.
Save gouthambs/873ebce21062914f038d to your computer and use it in GitHub Desktop.
Minimal Luigi Example
# 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