Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plugin] Numpy dtypes integration #2753

Open
Tracked by #2917
cosmicBboy opened this issue Aug 9, 2022 · 7 comments · May be fixed by flyteorg/flytekit#1258
Open
Tracked by #2917

[Plugin] Numpy dtypes integration #2753

cosmicBboy opened this issue Aug 9, 2022 · 7 comments · May be fixed by flyteorg/flytekit#1258
Assignees
Labels
good first issue Good for newcomers plugins Plugins related labels (backend or frontend) review-needed

Comments

@cosmicBboy
Copy link
Contributor

cosmicBboy commented Aug 9, 2022

Currently, only numpy arrays are supported by the numpy type extension. It would be useful to also support scalar data types as well.

So today, this code will not work:

import numpy as np
from flytekit import task, workflow

@task
def my_task() -> float:
    x = np.array([1,2,3])
    return x.mean()

@workflow
def wf():
    my_task()

wf()

Error:

TypeError: 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

@cosmicBboy cosmicBboy added the plugins Plugins related labels (backend or frontend) label Aug 10, 2022
@SmritiSatyanV
Copy link
Contributor

Could I work on this? @cosmicBboy

@aryamans29002
Copy link

can i work on this @cosmicBboy

@techytushar
Copy link

Hey @cosmicBboy ,
I have created a PR to fix this flyteorg/flytekit#1219
Please can you check if this is the right way to solve this, so I can go ahead and add the tests as well

@P3rcy-8685
Copy link

I would like to work on this @cosmicBboy

@samhita-alla
Copy link
Contributor

Since @techytushar created a PR already, I assigned the issue to Tushar.

Copy link

Hello 👋, this issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will engage on it to decide if it is still applicable.
Thank you for your contribution and understanding! 🙏

@github-actions github-actions bot added the stale label Apr 11, 2024
@Monis-Ahmed-Rizvi
Copy link

I’d like to take on this issue if no one else is working on it.

@github-actions github-actions bot removed the stale label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers plugins Plugins related labels (backend or frontend) review-needed
Projects
None yet
7 participants