如何运行此Luigi Task- TaskClassNotFoundException(cls._missing_task_msg(name))

时间:2018-07-24 11:25:36

标签: python luigi

我正在尝试在名为test.py的命令提示符和名为Test的类中运行1个luigi任务

luigi -m test Test --local-scheduler 

如何传递参数并在ubuntu中运行它

代码示例:

class Test: 

    def requires(self):
        return class1(param1='path', param2='', param3=123)

    def run(self):
        # some logic with using those 3 params

    def output(self):
        pass

class Class1(luigi.Task):

    param1 = luigi.Parameter()
    fileparam = file
    param2 = luigi.Parameter(default=fileparam)
    param3 = luigi.Parameter(default=123)

但我收到此错误

File "/home/ubuntu/.local/bin/luigi", line 11, in <module>
sys.exit(luigi_run())
File "/home/ubuntu/.local/lib/python3.5/site-packages/luigi/cmdline.py", line 11, in luigi_run
run_with_retcodes(argv)
File "/home/ubuntu/.local/lib/python3.5/site-packages/luigi/retcodes.py", line 69, in run_with_retcodes
with luigi.cmdline_parser.CmdlineParser.global_instance(argv):
File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/home/ubuntu/.local/lib/python3.5/site-packages/luigi/cmdline_parser.py", line 52, in global_instance
new_value = CmdlineParser(cmdline_args)
File "/home/ubuntu/.local/lib/python3.5/site-packages/luigi/cmdline_parser.py", line 76, in __init__
Register.get_task_cls(root_task)
File "/home/ubuntu/.local/lib/python3.5/site-packages/luigi/task_register.py", line 179, in get_task_cls
**raise TaskClassNotFoundException(cls._missing_task_msg(name))
luigi.task_register.TaskClassNotFoundException: No task Test.** Candidates are: Config,ExternalTask,RangeBase,RangeByMinutes,RangeByMinutesBase,RangeDaily,RangeDailyBase,RangeHourly,RangeHourlyBase,Task,TestNotificationsTask,WrapperTask,batch_email,core,email,execution_summary,retcode,scheduler,sendgrid,smtp,worker

2 个答案:

答案 0 :(得分:0)

尝试使用脚本在目录中运行此命令: python scrptfilenape.py Task --scheduler-host localhost

答案 1 :(得分:0)

如果文件是这样放置的

./test/__init__.py
./test/test.py

然后你需要运行

luigi -m test.test Test --local-scheduler