Skip to content

Instantly share code, notes, and snippets.

@samuell
Created March 18, 2014 17:36
Show Gist options
  • Select an option

  • Save samuell/9625123 to your computer and use it in GitHub Desktop.

Select an option

Save samuell/9625123 to your computer and use it in GitHub Desktop.
import luigi
from SomePossibleUpstreamTask import SomePossibleUpstreamTask
from SomeOtherPossibleUpstreamTask import SomeOtherPossibleUpstreamTask
class ExampleTask(luigi.Task):
upstream_task = luigi.Parameter()
def requires(self):
# This will return the upstream task object
return self.upstream_task
def output(self):
# A simple file naming scheme where the input file name is used,
# and just combined with an additional extension.
return luigi.LocalTarget(self.input().path + ".newextension")
def run(self):
# Loop over the input file, do something to each line, and
# write to the output file.
with self.input().open() as infile, self.output().open() as outfile:
for line in infile:
outfile.writeline(do_something(line))
def do_something(self, line):
pass # TODO: implement function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment