Can `pyflyte run` handle files? like if the input...
# ask-the-community
d
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
it does, but lot of improvements coming soon
if you want to help me test it
d
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