cuddly-jelly-27016
11/06/2024, 6:12 PM_make_dataset_serializable
, we intend to select the first argument in get_args(python_type)
because Optional
is equivalent to Union[ExpectedType, None]
. However, this approach may fail if the type order differs, for example, in Union[None, ExpectedType]
.
An error reproduction example:
from dataclasses import dataclass
from flytekit import task
from flytekit.types.file import FlyteFile
from typing import Union
@dataclass
class InnerDC:
ff: Union[None, FlyteFile]
@dataclass
class DC:
inner_dc: InnerDC
@task
def t_dc() -> DC:
return DC(inner_dc=InnerDC(ff="s3://path"))
Expected behavior
This code snippet should work, meaning that the underlying Union types in dataclasses should be serialized correctly.
Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn't been raised already?
• Yes
Have you read the Code of Conduct?
• Yes
flyteorg/flytecuddly-jelly-27016
11/06/2024, 6:12 PM