flyteorg / flyte

Scalable and flexible workflow orchestration platform that seamlessly unifies data, ML and analytics stacks.
https://flyte.org
Apache License 2.0
5.81k stars 661 forks source link

[BUG] [flytekit] cannot pass dataclass with Optional[list] to FlyteRemote.execute #6057

Open gvogel-hh opened 1 day ago

gvogel-hh commented 1 day ago

Describe the bug

When trying to pass a dataclass containing an optional list as input to FlyteRemote.execute(), a KeyError: 'items' is raised at flytekit/core/type_engine.py:839 in generate_attribute_list_from_dataclass_json_mixin (flytekit==1.13.14).

Expected behavior

Workflow is started with the given dataclass instance.

Additional context to reproduce

from dataclasses import dataclass
from typing import Optional

from flytekit import task, workflow
from flytekit.configuration import Config
from flytekit.remote import FlyteRemote
from mashumaro.mixins.json import DataClassJSONMixin

@dataclass
class MyConfig(DataClassJSONMixin):
    op_list: Optional[list[str]]

@task
def t() -> None:
    pass

@workflow
def wf(config: MyConfig) -> None:
    t()

if __name__ == "__main__":
    config = MyConfig(op_list=["a", "b"])
    remote = FlyteRemote(
        config=Config.auto(config_file="../config.yaml"),
        default_project="flytesnacks",
        default_domain="development",
    )

    remote_wf = remote.fetch_workflow(name="mywf.wf")
    execution = remote.execute(remote_wf, inputs={"config": config})

Screenshots

No response

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

Have you read the Code of Conduct?

welcome[bot] commented 1 day ago

Thank you for opening your first issue here! 🛠