flyteorg / flyte

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

[Housekeeping] [flytekit] Investigate better handling of incorrect dataclass/enum types #2267

Open wild-endeavor opened 2 years ago

wild-endeavor commented 2 years ago

Describe the issue

Issue originally reported in https://flyte-org.slack.com/archives/C01P3B761A6/p1647360364170899

from dataclasses import dataclass
from dataclasses_json import dataclass_json
from enum import Enum

from flytekit import task, workflow

# ERROR: having these two annotations causes
# TypeError: __call__() missing 1 required positional argument: 'value'
@dataclass_json
@dataclass
class Aggregation(Enum):
    GROUP_1x1 = "1x1"
    GROUP_5x1 = "5x1"

@dataclass_json
@dataclass
class Nested:
    agg: Aggregation

@task
def tsk(nested: Nested):
    if nested.agg == Aggregation.GROUP_1x1:
        print("1x1")
    elif nested.agg == Aggregation.GROUP_5x1:
        print("5x1")
    else:
        raise ValueError("bad aggregation value")

@workflow
def wf():
    a = tsk(nested=Nested(agg=Aggregation.GROUP_1x1))

if __name__ == "__main__":
    wf()

The combination of dataclass and Enum (which shouldn't be done) causes errors that are hard to understand. Investigate whether flytekit can report this error any better.

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

Have you read the Code of Conduct?

github-actions[bot] commented 1 year ago

Hello πŸ‘‹, This issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will close the issue if we detect no activity in the next 7 days. Thank you for your contribution and understanding! πŸ™

github-actions[bot] commented 1 year ago

Hello πŸ‘‹, This issue has been inactive for over 9 months and hasn't received any updates since it was marked as stale. We'll be closing this issue for now, but if you believe this issue is still relevant, please feel free to reopen it. Thank you for your contribution and understanding! πŸ™

github-actions[bot] commented 3 months ago

Hello πŸ‘‹, this issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will engage on it to decide if it is still applicable. Thank you for your contribution and understanding! πŸ™