<#2806 [BUG] By default, FlyteDirectory is empty w...
# flyte-github
a
#2806 [BUG] By default, FlyteDirectory is empty when executing workflow on Flyte cluster Issue created by cosmicBboy Describe the bug To reproduce, register and run these tasks and workflows on a local
flytectl demo
cluster:
Copy code
from pathlib import Path
from typing import List

from flytekit import task, workflow
from flytekit.types.directory import FlyteDirectory


@task
def create_directory() -> FlyteDirectory:
    path = Path("/tmp/flytekit-testing")
    path.mkdir(exist_ok=True, parents=True)
    for file in ["file1.txt", "file2.txt"]:
        with (path / file).open("w") as f:
            f.write("hey\n")
    return FlyteDirectory(path=str(path))


@task
def downstream_task(directory: FlyteDirectory) -> List[str]:
    output = []
    for file in Path(directory.path).glob("*"):
        output.append(str(file))
        print(file)
    return output


@workflow
def wf() -> List[str]:
    return downstream_task(bento_model=create_directory())


if __name__ == "__main__":
    wf()
You'll find that the output of the
downstream_task
contains no filepath strings:

image▾

Expected behavior I would expect the files to be in the
directory.path
. Instead, I need to explicitly call
directory.download()
to get those files there. Why is this a problem? Because the local and remote experiences are divergent: if I just run the tasks above with
python
, the files are there. But when executing remotely, now I need to change my code to
.download()
the files. Potential Solutions 1. automatically download the files 2. raise an exception if the
directory.path
is invoked but
directory.downloaded == False
3. make the local python experience equivalent to the remote one: force the user to invoke
download()
. 4. others? 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/flyte