[BUG] Regression when registering Empty Default complex values for parameters after Union/Sumtype support
Describe the bug
PR https://github.com/flyteorg/flytepropeller/pull/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?
- [X] Yes
Have you read the Code of Conduct?
- [X] Yes
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.
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.