brief-family-9488
08/25/2025, 7:59 PMjolly-florist-66728
08/25/2025, 7:59 PMjolly-florist-66728
08/25/2025, 8:01 PMfrom dataclasses import dataclass
from flytekit import task, workflow
@dataclass
class MyStruct:
a: int
b: str
@task
def my_task(x: MyStruct) -> int:
return x.a
@workflow
def my_wf(x: MyStruct) -> int:
return my_task(x=x)
You can launch this workflow and provide the input as a JSON object, e.g., {"a": 1, "b": "hello"}
. For more, see the Flyte dataclass documentation and related issue.
Would you like more detail or examples for Pydantic models or advanced struct usage?
Sources:
- Flyte dataclass documentation
- Flyte issue: Unable to input dataclass and optional dataclass types in Flyte Console š 0 button š 0 button š” Hint: Mention @runllm in the thread for followups.brief-family-9488
08/25/2025, 9:36 PMjolly-florist-66728
08/25/2025, 9:36 PMjolly-florist-66728
08/25/2025, 9:37 PMfrom dataclasses import dataclass
@dataclass
class SinkTable:
name: str
id: int
You should call FlyteRemote like this:
inputs = {"sink_table": {"name": "my_table", "id": 123}}
execution = remote.execute(workflow, inputs=inputs)
Passing a dataclass instance directly will result in a type mismatch (simple:BINARY
instead of simple:STRUCT
). For more, see the Flyte dataclass docs and related issue.
Would you like more detail or troubleshooting steps?
Sources:
- Flyte dataclass documentation
- Flyte issue: Unable to input dataclass and optional dataclass types in Flyte Console š 0 button š 0 button š” Hint: Mention @runllm in the thread for followups.brief-family-9488
08/25/2025, 10:31 PMjolly-florist-66728
08/25/2025, 10:31 PMjolly-florist-66728
08/25/2025, 10:31 PMbrief-family-9488
08/25/2025, 10:40 PMjolly-florist-66728
08/25/2025, 10:40 PMjolly-florist-66728
08/25/2025, 10:41 PMimport os
os.environ["FLYTE_USE_OLD_DC_FORMAT"] = "true"
from flytekit.remote import FlyteRemote
# ... rest of your code
This ensures Flytekit serializes dataclasses using the legacy Protobuf struct format, which may be required for compatibility with older Flyte backends. See Flyte dataclass documentation and Flyte PR 5991.
Would you like more detail on version compatibility or troubleshooting?
Sources:
- Flyte dataclass documentation
- Flyte PR 5991 š 1 button š 0 button š” Hint: Mention @ancient-wolf-19325 in the thread for followups.brief-family-9488
08/25/2025, 11:12 PMjolly-florist-66728
08/25/2025, 11:12 PMjolly-florist-66728
08/25/2025, 11:13 PMfrom dataclasses import dataclass
from flytekit import task, workflow
@dataclass
class MyData:
foo: int
bar: str
@task
def t1(x: MyData) -> MyData:
return x
@workflow
def subwf(x: MyData) -> MyData:
return t1(x=x)
@workflow
def main_wf(x: MyData) -> MyData:
return subwf(x=x)
This pattern is supported and tested in Flyte, including for nested dataclasses. For more, see this integration test example.
Would you like more detail or examples with nested dataclasses?
Sources:
- Flyte dataclass_with_optional_wf.py example š 0 button š 0 button š” Hint: Mention @runllm in the thread for followups.