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

Differentiate 0 and unset as a default param values #33965

Merged

Conversation

SamWheating
Copy link
Contributor

@SamWheating SamWheating commented Aug 31, 2023

Re: #33923

Pretty self explanatory, since python's zero is falsey, using {% if form.details.value %} led to the default value being omitted if it was a zero. This minor change makes a zero default value explicitly zero, and if a user wants to default to null they can use something like:

Param(None, type=["integer", "null"])

So given the following DAG:

with DAG(
    "params-dag",
    schedule=None,
    params={
        "integer_param": Param(5, type="integer"),
        "zero_integer_param": Param(0, type="integer"),
        "unset_integer_param": Param(None, type=["integer", "null"]),
    },
) as dag:

This was the default form before:
image

And this is it after:
image

List-type params are a whole different problem, and there's a lot of discussion in the original issue, so lets leave that for another PR? In the current implementation there's no way to explicitly pass an empty list through the form interface so I think that some changes will be definitely be required.

@boring-cyborg boring-cyborg bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Aug 31, 2023
@potiuk potiuk added this to the Airflow 2.7.1 milestone Aug 31, 2023
@potiuk
Copy link
Member

potiuk commented Aug 31, 2023

Nice. Thanks Again @SamWheating . You are our 2.7.0 bug-squasher.

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

I was thinking about using {% if form_details.value is number %} but checking against not none is also good :-D

@matteoannotell
Copy link

Thanks for the quick solution @SamWheating, much appreciated 🙏

@hussein-awala hussein-awala merged commit c51901a into apache:main Aug 31, 2023
42 checks passed
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Sep 1, 2023
ephraimbuddy pushed a commit that referenced this pull request Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants