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] Regression when registering Empty Default complex values for parameters after Union/Sumtype support #2424

Closed
2 tasks done
kumare3 opened this issue Apr 27, 2022 · 2 comments · Fixed by flyteorg/flytepropeller#433
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kumare3
Copy link
Contributor

kumare3 commented Apr 27, 2022

Describe the bug

PR flyteorg/flytepropeller#373 added support for union types, but also removed an extra check that allows having None values as default values for types like collections.
This change introduced a regression, that affects empty defaults for a workflow parameter. Example

@workflow
def wf2m(i: Dict[str, int] = {}) -> Dict[str, int]:
    return t2(i=i)

OR

@workflow
def wf(l: List[str] = []) -> List[str]:
    return t1(l=l)

Compilation now fails. This is because, in protobuf to represent an empty type the only option is to support empty messages.

The empty type check happens in Flyteadmin here
Note, that the default value is not None, and the guessed type for an empty list - [] is of type collection:None
After the PR#373 the isVoid check was removed, which implies that collection:None is no longer castable to collection:int

I think one of the problems is guessing the type on the RHS, but there does not seem to be a better option

Expected behavior

Users should be able to use
l = [] or m = {} as default values

Additional context to reproduce

Simple example that can fail

from flytekit import workflow, task
from typing import List, Dict

@task
def t1(l: List[str]) -> List[str]:
    return l


@workflow
def wf(l: List[str] = []) -> List[str]:
    return t1(l=l)


@task
def t2(i: Dict[str, int]) -> Dict[str, int]:
    return i

@workflow
def wf2m(i: Dict[str, int] = {}) -> Dict[str, int]:
    return t2(i=i)

Example generated struct for Default

parameters {
  key: "i"
  value {
    var {
      type {
        map_value_type {
          simple: INTEGER
        }
      }
      description: "i"
    }
    default {
      map {
      }
    }
  }

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@kumare3 kumare3 added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers and removed untriaged This issues has not yet been looked at by the Maintainers labels Apr 27, 2022
@kumare3 kumare3 self-assigned this Apr 27, 2022
@kumare3 kumare3 added this to the 1.0.1 milestone Apr 27, 2022
@kumare3 kumare3 assigned EngHabu and unassigned kumare3 Apr 28, 2022
@convexquad
Copy link
Contributor

convexquad commented May 4, 2022

FYI a user reported also having to change:

Input(
        Types.String,
        help='State date string',
        default=None,
    )

to default='' instead. It is possible that having None as the default value broadly triggers this issue.

@DobsX
Copy link

DobsX commented May 6, 2022

I see the PR is in which is good, but FYI, it's impossible to even send an empty string using the UI. So the work-around of default='' unfortunately only works if launching programmatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants