Skip to content

Commit

Permalink
test: Add another ff use case
Browse files Browse the repository at this point in the history
Create ff in one task pod and read it in another task pod.

Signed-off-by: JiaWei Jiang <waynechuang97@gmail.com>
  • Loading branch information
JiangJiaWei1103 committed Jan 2, 2025
1 parent 718727b commit 3c02d19
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions tests/flytekit/integration/remote/workflows/basic/flytefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@


@task
def open_ff_from_remote(remote_file_path: str) -> FlyteFile:
"""Open FlyteFile from a remote file path.
def create_ff(file_path: str) -> FlyteFile:
"""Create a FlyteFile."""
return FlyteFile(path=file_path)


@task
def read_ff(ff: FlyteFile) -> None:
"""Read input FlyteFile.
This can be used in the case in which a FlyteFile is created
in another task pod and read in this task pod.
"""
with open(ff, "r") as f:
content = f.read()
print(f"FILE CONTENT | {content}")


@task
def create_and_read_ff(file_path: str) -> FlyteFile:
"""Create a FlyteFile and read it.
Both FlyteFile creation and reading are done in this task pod.
Args:
remote_file_path: Remote file path.
file_path: File path.
Returns:
ff: FlyteFile object.
"""
ff = FlyteFile(path=remote_file_path)
ff = FlyteFile(path=file_path)
with open(ff, "r") as f:
content = f.read()
print(f"FILE CONTENT | {content}")
Expand All @@ -22,7 +42,10 @@ def open_ff_from_remote(remote_file_path: str) -> FlyteFile:

@workflow
def wf(remote_file_path: str) -> None:
remote_ff = open_ff_from_remote(remote_file_path=remote_file_path)
ff_1 = create_ff(file_path=remote_file_path)
read_ff(ff=ff_1)
ff_2 = create_and_read_ff(file_path=remote_file_path)
read_ff(ff=ff_2)


if __name__ == "__main__":
Expand Down

0 comments on commit 3c02d19

Please sign in to comment.