For local files, FlyteDirectory.listdir returns only the names of the files/dirs in the given directory, not the full paths. This breaks the following workflow.
import tempfile
from pathlib import Path
from flytekit import FlyteDirectory, FlyteFile, map_task, task, workflow
@task
def setup() -> FlyteDirectory:
tmpdir = Path(tempfile.mkdtemp())
for i in range(3):
(tmpdir / f"file{i}.txt").write_text(f"Hello, World! {i}")
return FlyteDirectory(tmpdir)
@task
def read_file(file: FlyteFile) -> str:
with open(file, "r") as f:
return f.read()
@task
def list_dir(dir: FlyteDirectory) -> list[FlyteFile]:
return FlyteDirectory.listdir(dir)
@workflow
def wf() -> list[str]:
tmpdir = setup()
files = list_dir(dir=tmpdir)
return map_task(read_file)(file=files)
Run with pyflyte run debug_flyte.py wf.
This issue arises because only the file/dir name is returned, not the joined path here.
Running Execution on local.
FlyteAssertion: USER:AssertionError: error=Error encountered while converting inputs of 'debug_flyte.map_read_file_6b3bd0353da5de6e84d7982921ead2b3-arraynode':
Cannot convert from Flyte Serialized object (Literal):
scalar:
blob:
metadata:
uri: file0.txt to <class 'flytekit.types.file.file.FlyteFile'>. Expected a file, but file0.txt is not a file.
Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn't been raised already?
Describe the bug
Thanks for this great library!
For local files,
FlyteDirectory.listdir
returns only the names of the files/dirs in the given directory, not the full paths. This breaks the following workflow.Run with
pyflyte run debug_flyte.py wf
.This issue arises because only the file/dir name is returned, not the joined path here.
Expected behavior
I would expect to get the outputs:
(in some order), but instead I get
Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?