acoustic-carpenter-78188
11/02/2023, 9:26 PMfrom 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?
☑︎ Yes
Have you read the Code of Conduct?
☑︎ Yes
flyteorg/flyteacoustic-carpenter-78188
11/02/2023, 9:26 PM