Skip to content

[BUG] dataclass and pydantic both failed when using Flytekit Remote API #6081

Open
@Future-Outlier

Description

Describe the bug

Take dataclass as an example, if you use a dataclass as a task's input or output, and you use the flytekit remote API to fetch the result, you will get an error.

example code

from flytekit.remote.remote import FlyteRemote
from flytekit.configuration import Config
remote = FlyteRemote(
    Config.for_endpoint("localhost:30080", True),
)
o = remote.get("flyte://v1/flytesnacks/development/am8tmmtmlnht4627qc4z/dataclassexamplet1/o") # this is a datacalss or pydantic basemodel
print(o['o0'])

error

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /Users/future-outlier/code/dev/flytekit/build/pydantic/dataclass_remote_api. │
│ py:12 in <module>                                                            │
│                                                                              │
│ ❱ 12 print(o['o0'])                                                          │
│                                                                              │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/type_engine.py:2648 in │
│ __getitem__                                                                  │
│                                                                              │
│ ❱ 2648 │   │   return self.get(key)                                          │
│                                                                              │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/type_engine.py:2676 in │
│ get                                                                          │
│                                                                              │
│ ❱ 2676 │   │   │   │   │   raise ValueError("as_type argument not supplied a │
╰──────────────────────────────────────────────────────────────────────────────╯
ValueError: as_type argument not supplied and Variable map not specified in 
LiteralsResolver

Expected behavior

This should work.

Additional context to reproduce

@dataclass
class A:
    a: int
    b: float

@task(container_image=image)
def t1(a: A) -> A:
    print(a)
    return a

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 workingflytekitFlyteKit Python related issue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions