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

Optional parameter #2295

Merged
merged 2 commits into from
Dec 11, 2017
Merged

Optional parameter #2295

merged 2 commits into from
Dec 11, 2017

Conversation

daveFNbuck
Copy link
Contributor

Description

Create an OptionalParameter class that serializes None as the empty string and use this class whenever we have a parameter with default None. Empty string gets parsed to None.

Motivation and Context

I get a long series of type warnings from default None values in the Luigi codebase whenever I run my pipeline. This gets rid of those, and should be safe as long as no one needs to differentiate between the empty string and None.

Have you tested this? If so, how?

I added some unit tests for the OptionalParameter class. I haven't tried running a pipeline with it yet, but I will soon.

This allows a parameter to be a string or None. None is serialized as
an empty string, and empty strings parse as None. This is useful for
luigi.Config classes where we want a None value for some parameters
and don't want warnings about the type being wrong.
This will reduce warnings in the scheduler. It should be safe unless
there are cases where the empty string needs to be distinguished from
None. That doesn't seem to be the case anywhere here.
Copy link
Contributor

@Tarrasch Tarrasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@daveFNbuck
Copy link
Contributor Author

Forgot to update this, but I've been using this in production about 2 weeks now and it works fine.

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

Successfully merging this pull request may close these issues.

3 participants