https://flyte.org logo
#flytekit
Title
# flytekit
s

seunggs

10/20/2022, 8:45 PM
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

seunggs

10/21/2022, 5:50 AM
Hi @Eduardo Apolinario (eapolinario) thanks - the docs say to use python 3 type hints though. What is the difference?
e

Eduardo Apolinario (eapolinario)

10/21/2022, 9:01 PM
@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

seunggs

10/22/2022, 1:58 AM
Thanks for the explanation - I’ll def check out the docs you sent!
70 Views