cuddly-jelly-27016
05/22/2025, 12:09 AMTypeError: Failed to convert return value for var o0 for function my_task with error <class 'flytekit.core.type_engine.TypeTransformerFailedError'>: Expected value of type <class 'float'> but got type <class 'numpy.float64'>
Problem: flytekit doesn't know how to handle numpy.<dtype> scalar types. The code above will show up anywhere where a user wants to aggregate some values using numpy operations (including sklearn, and probably a bunch of others)
Of course the user can always do float(x.mean()) to convert it to a normal float, but then this kills UX because now we're forcing users to modify otherwise functioning code into some flytekit-nitpicky syntax.
### Potential Solutions
1. Create a set of type transformers for numpy scalar dtypes
2. Modify existing primitive type transformers (see here) to recognize numpy types.
#### Resources
• numpy scalar types: https://numpy.org/doc/stable/reference/arrays.scalars.html
flyteorg/flytecuddly-jelly-27016
05/22/2025, 12:09 AM