acoustic-carpenter-78188
12/31/2022, 12:29 AMOptional[FlyteFile] correctly.
For example, this workflow fails:
from dataclasses import dataclass
from typing import Optional
from dataclasses_json import dataclass_json
from flytekit import workflow, task
from flytekit.types.file import FlyteFile
@dataclass_json
@dataclass
class TaskOutput:
    file1: FlyteFile
    file2: Optional[FlyteFile]
@task
def task1() -> TaskOutput:
    with open("file21.txt", "w+") as f:
        f.write("b")
    with open("file22.txt", "w+") as f:
        f.write("c")
    return TaskOutput(
        FlyteFile("file21.txt", remote_path="<s3://my-s3-bucket/tmp/file21.txt>"),
        FlyteFile("file22.txt", remote_path="<s3://my-s3-bucket/tmp/file22.txt>")
    )
@task
def assert_values_in_dataclass(to: TaskOutput):
    assert to.file1.remote_source == "<s3://my-s3-bucket/tmp/file21.txt>"
    assert to.file2.remote_source == "<s3://my-s3-bucket/tmp/file22.txt>"
@workflow
def wf():
    to = task1()
    assert_values_in_dataclass(to=to)
Expected behavior
Optional[FlyteFile] should be allowed in Dataclasses.
Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn't been raised already?
☑︎ Yes
Have you read the Code of Conduct?
☑︎ Yes
flyteorg/flyteacoustic-carpenter-78188
12/31/2022, 12:29 AMFlyte enables production-grade orchestration for machine learning workflows and data processing created to accelerate local workflows to production.
Powered by