bastionlab icon indicating copy to clipboard operation
bastionlab copied to clipboard

Polars: The enum variant Expr::AnonymousFunction cannot be serialized

Open cchudant opened this issue 2 years ago • 1 comments

Any usage of value_counts fails with this error:

rdf.select(pl.col("gender").value_counts()).collect().fetch()

Error: ValueError: Error("the enum variant Expr::AnonymousFunction cannot be serialized", line: 0, column: 0)

As @lyie28 told me, this is also the case for these operators:

  • abs()
  • unique_counts()
  • is_finite()
  • is_first()
  • is_inifinite()

Additional context from @lyie28:

I spoke to Lucas about this and it seems this is probably because some Polars functions were implemented using user defined function with lambdas which we can't support, whereas they have updated many of their functions to have a different kind of implementation which we can support. So it might be that with time, Polars updates some of these functions to something we can support anyway, but otherwise, we would need to slowly implement them one by one, probably as torch script implementations (or occasionally it may be possible by combining available Polars methods- like unique().count() instead of unique_counts()). I am working on some other stuff now but might come back to this

Feel free to postpone, or close this issue if this is deemed infeasible – although in this case a better error message would probably be welcome

cchudant avatar Jan 12 '23 14:01 cchudant

I suggest we improve error reporting as Charles suggested

dhalf avatar Jan 13 '23 10:01 dhalf