Skip to content

Instantly share code, notes, and snippets.

@drj42
Created November 21, 2015 16:32
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 drj42/c22808a141761356c733 to your computer and use it in GitHub Desktop.
Save drj42/c22808a141761356c733 to your computer and use it in GitHub Desktop.
TaskParameter quirks
import luigi
class Foo(luigi.Task):
message = 'Foo'
class RunOnceTask(luigi.Task):
my_task = luigi.TaskParameter()
_comp = False
def complete(self):
return RunOnceTask._comp
def run(self):
print('\n==> TASK:{}, TYPE:{}\n'.format(
self.my_task, type(self.my_task)))
RunOnceTask._comp = True
# Task param passed as class name
class A1(luigi.Task):
"""Works as expected."""
def requires(self):
yield RunOnceTask(my_task=Foo)
class A2(luigi.Task):
"""But then this fails... luigi.task_register.TaskClassNotFoundException"""
def run(self):
yield RunOnceTask(my_task=Foo)
# Task class passed as string
class B1(luigi.Task):
"""Task runs, but task parameter is parsed as a string, not task."""
def requires(self):
yield RunOnceTask(my_task='Foo')
class B2(luigi.Task):
"""Works. Task string converted to task class."""
def run(self):
yield RunOnceTask(my_task='Foo')
if __name__ == '__main__':
luigi.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment