Hi what should be the return type hint for a file ...
# flytekit
s
Hi what should be the return type hint for a file or pickle file? Looks like in python, file type annotation should be
typing.TextIO
or
typing.BinaryIO
but not sure what they should be for flyte?
s
Hi @Eduardo Apolinario (eapolinario) thanks - the docs say to use python 3 type hints though. What is the difference?
e
@seunggs, sorry I missed this notification. First, give https://docs.flyte.org/en/latest/concepts/data_management.html#data-movement a read. Essentially FlyteFile has a few advantages: 1. it abstracts away the work to upload/download a file, 2. it integrates with other portions of the Flyte programming model, e.g. shell tasks (i.e. you can pass flytefile as an input of a shelltask) 3. You can use the Flyte type system to capture the extension of your flytefile. For example, a task that returns
FlyteFile[csv]
cannot be used as an input to a task that takes a
FlyteFile[png]
as a parameter. 4. If you use the python type hints Flyte will simply pickle the file.
s
Thanks for the explanation - I’ll def check out the docs you sent!
154 Views