Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: parameter doesn't preserve default None value after yield #3226

Open
natalevichmv opened this issue Feb 10, 2023 · 0 comments
Open

Bug: parameter doesn't preserve default None value after yield #3226

natalevichmv opened this issue Feb 10, 2023 · 0 comments

Comments

@natalevichmv
Copy link

natalevichmv commented Feb 10, 2023

When you have a task with a parameter that defaults to None, it converts to str("None") if the task is yielded from run(), but remains None if a task is returned from requires() method.

When I run the following code with luigi --module <module> YieldTask --local-scheduler, the file yield.txt contains <class 'str'>.
When I run the following code with luigi --module <module> ReturnTask --local-scheduler, the file return.txt contains <class 'NoneType'>.

import luigi

class ParamTask(luigi.Task):
    none_param = luigi.Parameter(default=None)
    name_param = luigi.Parameter()

    def run(self):
        with self.output().open('w') as f:
            f.write(str(type(self.none_param)))

    def output(self):
        return luigi.LocalTarget(f'{self.name_param}.txt')

class YieldTask(luigi.Task):
    def run(self):
        yield ParamTask(name_param='yield')

class ReturnTask(luigi.Task):
    def requires(self):
        return ParamTask(name_param='return')

luigi version: 3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant