https://flyte.org logo
#ask-the-community
Title
# ask-the-community
d

Dan Farrell

10/19/2023, 6:45 PM
Can
pyflyte run
handle files? like if the input to a workflow is a file, how should I go about that?
ex:
Copy code
from flytekit import workflow, task
from flytekit.types.file import FlyteFile


@task
def task_long(f_in: FlyteFile) -> int:
    data = f_in.open("r").read()
    print(data)
    ret = len(data)
    return ret


@workflow
def runme(input_file: FlyteFile) -> int:
    return task_long(input_file)
run:
Copy code
$ pyflyte run   --remote  tmptest.py runme --input_file ./1ycr.pdb
Failed with Exception Code: USER:AssertionError
Underlying Exception: When calling tasks, only keyword args are supported. Aborting execution as detected 1 positional args (Promise(node:.input_file),)
Error encountered while executing 'runme':
  When calling tasks, only keyword args are supported. Aborting execution as detected 1 positional args (Promise(node:.input_file),)
edit: oops, moron, sorry for the noise: it works, it was just a missing kwarg -_ - of course should have read better
Final working script:
Copy code
from flytekit import workflow, task, dynamic
from flytekit.types.file import FlyteFile


@task
def task_long(f_in: FlyteFile) -> int:
    with f_in.open("r") as fh:
        data = fh.read()
    print(data)
    ret = len(data)
    return ret


@workflow
def runme(input_file: FlyteFile) -> int:
    return task_long(f_in=input_file)
k

Ketan (kumare3)

10/19/2023, 8:32 PM
it does, but lot of improvements coming soon
if you want to help me test it
d

Dan Farrell

10/19/2023, 9:31 PM
interesting... as of right now I don't really care where my inputs are going, but I could see needing such a feature in the future
4 Views