Skip to content

[BUG] [flytekit] Task with input containing Enum inside dataclass fails when executing with flytekit remote access #6155

Open
@pimdh

Description

Describe the bug

Consider following task definition:

from dataclasses import dataclass
from enum import Enum

from flytekit import FlyteRemote, task
from flytekit.configuration import Config

class B(Enum):
    X = "x"
    Y = "y"


@dataclass
class A:
    b: B


@task
def flyte_test_task(a: A) -> None:
    print(a)

Then register. Then execute with:

PROJECT = ...
DOMAIN = ...
remote = FlyteRemote(config=Config.auto())
task = remote.fetch_task(name="flyte_test_task", project=PROJECT, domain=DOMAIN)

execution = remote.execute(
    task,
    project=PROJECT,
    domain=DOMAIN,
    inputs={"a": A(b=B.X)},
)

This triggers error:

TypeTransformerFailedError: Type of Val '<enum 'B'>' is not an instance of <class 'str'>

If the enum is not inside a dataclass, but an argument to the task itself, the bug does not occur.

Expected behavior

The execution should be successfully created.

If instead I submit via the CLI

pyflyte run -p PROJECT -d DOMAIN remote-task flyte_test_task --a '{"b": "x"}'

The execution is created as expected.

Additional context to reproduce

Using flytekit version 1.14.3

Screenshots

No response

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

  • Yes

Have you read the Code of Conduct?

  • Yes

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions