Question about passing polars dataframes between t...
# flyte-support
f
Question about passing polars dataframes between tasks: In theory the
flytekitplugin-polars
package should automatically get the return signature from the following function
Copy code
def random_dataframe(num_rows: int) -> pl.DataFrame:
    feature_1_list = np.random.randint(low=100, high=999, size=(num_rows,))
    feature_2_list = np.random.normal(loc=0, scale=1, size=(num_rows, ))
    feature_3_list = [make_random_protein(x) for x in feature_1_list]
    return pl.DataFrame({'protein_length': feature_1_list,
                         'protein_feature': feature_2_list,
                         'protein_seq': feature_3_list})
and handle the conversion to
flytekit.types.structured.structured_dataset.StructuredDataset
when moving it between tasks. In practice what I see is
Copy code
TypeError: Failed to convert outputs of task 'main_workflows.make_dataframe' at position 0. 
Failed to convert type <class 'polars.dataframe.frame.DataFrame'> to type <class 'polars.dataframe.frame.DataFrame'>.
Error Message: 'coroutine' object does not support the asynchronous context manager protocol.

Message:

TypeError: Failed to convert outputs of task 'main_workflows.make_dataframe' at position 0.
Failed to convert type <class 'polars.dataframe.frame.DataFrame'> to type <class 'polars.dataframe.frame.DataFrame'.
Error Message: 'coroutine' object does not support the asynchronous context manager protocol.", "taskName": null}
Any idea as to what's going on?
h
cc: @thankful-minister-83577 We shipped a change to add support for python`asyncio` in flytekit 1.14.0. Seeing a mention to
coroutine
there, so flagging just as a potential cause. @freezing-tailor-85994, can you confirm which versions of
flytekit
and
flytekitplugin-polars
you're using? Also, can you try running a version other than 1.14.0 ?
f
It's 1.14.0 on both, I can roll back to 1.13 and retest once I have some bandwidth
h
thank you. We'll investigate on our side as well and report back here.
f
@high-accountant-32689 confirming that 1.13 works fine
With 1.13 being stuck to polars 0.17 it's a bit of a problem for us since there's major syntax shifts (e.g apply -> map_elements)
t
no we’ll patch 14. let us repro first.
@freezing-tailor-85994 are you including a
uri
in the return statement?
f
@thankful-minister-83577 I am not, the function is exactly as listed above with a return of a pl.DataFrame and a type hint on the function definition
t
yeah thanks… we have a fix - this will get patched on monday
f
beautiful, thank you
t
can pull master if you need it earlier
f
@thankful-minister-83577 what's the ETA on 1.14.1 release?
t
need to backport prs…
please hold
apologies for the delay
f
thank you sir 🫡