brief-family-9488
10/17/2025, 4:15 AMancient-wolf-19325
10/17/2025, 4:15 AMbrief-family-9488
10/17/2025, 4:16 AMancient-wolf-19325
10/17/2025, 4:16 AMbrief-family-9488
10/17/2025, 4:22 AMancient-wolf-19325
10/17/2025, 4:22 AMbrief-family-9488
10/17/2025, 4:23 AMancient-wolf-19325
10/17/2025, 4:23 AMfrom flytekit import task, workflow
from flytekit.types.file import FlyteFile
@task
def create_files() -> tuple[FlyteFile, FlyteFile]:
# Write first file
with open("file1.txt", "w") as f1:
f1.write("This is file 1.")
# Write second file
with open("file2.txt", "w") as f2:
f2.write("This is file 2.")
# Return as FlyteFiles
return FlyteFile("file1.txt"), FlyteFile("file2.txt")
@workflow
def wf() -> tuple[FlyteFile, FlyteFile]:
return create_files()
Each returned FlyteFile will be uploaded to the Flyte blob store and can be used as input to downstream tasks. For more, see the FlyteFile documentation.
Sources:
- FlyteFile documentation π 0 button π 0 button π‘ Hint: Mention @runllm in the thread for followups.brief-family-9488
10/17/2025, 4:26 AMancient-wolf-19325
10/17/2025, 4:26 AMbrief-family-9488
10/17/2025, 4:36 AMancient-wolf-19325
10/17/2025, 4:36 AMfrom flytekit import task, workflow
from flytekit.types.file import FlyteFile
import os
def create_dir_and_files(base_dir: str):
os.makedirs(base_dir, exist_ok=True)
file1 = os.path.join(base_dir, "a.txt")
file2 = os.path.join(base_dir, "subdir", "b.txt")
os.makedirs(os.path.dirname(file2), exist_ok=True)
with open(file1, "w") as f:
f.write("File A")
with open(file2, "w") as f:
f.write("File B")
return file1, file2
@task
def create_files_task() -> tuple[FlyteFile, FlyteFile]:
file1, file2 = create_dir_and_files("mydir")
return FlyteFile(file1), FlyteFile(file2)
@workflow
def wf() -> tuple[FlyteFile, FlyteFile]:
return create_files_task()
This creates a directory with nested files and returns them as FlyteFiles. For more, see the FlyteFile documentation.
Sources:
- https://www.union.ai/docs/v2/flyte/user-guide/task-programming/files-and-directories/
- https://github.com/flyteorg/flytekit/blob/master/tests/flytekit/unit/core/test_local_raw_container.py π 0 button π 0 button π‘ Hint: Mention @runllm in the thread for followups.