Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Parameters in python luigi

Tags:

python

luigi

I have am triggering Luigi via

luigi.run(["--local-scheduler"], main_task_cls=Test(Server = ActiveServer, Database = DB))   

and in my class I have:

class Test(luigi.Task):

    Database = luigi.Parameter()
    Server = luigi.Parameter()

but the task test can't seem to parse the parameters that I'm feeding it properly?

I am getting:

MissingParameterException: No value for 'Server' (--Server) submitted and no default value has been assigned.
like image 264
KillerSnail Avatar asked Mar 16 '23 08:03

KillerSnail


1 Answers

As far as I know, you can not send the parameters through the main_task_cls argument, only the class itself. Parameters could instead be sent via the cmdline_args argument, like so:

luigi.run(
    cmdline_args=["--local-scheduler",
                  "--server=ActiveServer",
                  "--database=DB"], 
    main_task_cls=Test)

Note also that there is the local_scheduler keyword argument to luigi.run() that you can use instead of sending --local-scheduler through the cmdline_args argument, so you get:

luigi.run(
    cmdline_args=["--Server=ActiveServer",
                  "--Database=DB"], 
    main_task_cls=Test
    local_scheduler=True)
like image 176
Samuel Lampa Avatar answered Mar 24 '23 08:03

Samuel Lampa