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

TypeTransformer for Numpy #1027

Merged
merged 2 commits into from
May 28, 2022
Merged

TypeTransformer for Numpy #1027

merged 2 commits into from
May 28, 2022

Conversation

samhita-alla
Copy link
Contributor

Signed-off-by: Samhita Alla [email protected]

TL;DR

This PR adds support for numpy.ndarray as a native Flyte type.
One caveat: object Numpy arrays cannot be serialized and unserialized.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

flyteorg/flyte#2544

Follow-up issue

NA
OR
https://github.com/flyteorg/flyte/issues/

Signed-off-by: Samhita Alla <[email protected]>
Signed-off-by: Samhita Alla <[email protected]>
@codecov
Copy link

codecov bot commented May 27, 2022

Codecov Report

Attention: Patch coverage is 96.26866% with 5 lines in your changes missing coverage. Please review.

Project coverage is 86.52%. Comparing base (12ef34d) to head (63b561f).
Report is 1076 commits behind head on master.

Files Patch % Lines
flytekit/types/numpy/ndarray.py 88.88% 3 Missing and 1 partial ⚠️
tests/flytekit/unit/core/test_numpy.py 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1027      +/-   ##
==========================================
+ Coverage   86.39%   86.52%   +0.12%     
==========================================
  Files         255      264       +9     
  Lines       24417    24713     +296     
  Branches     2776     2781       +5     
==========================================
+ Hits        21096    21383     +287     
- Misses       2849     2855       +6     
- Partials      472      475       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


# save numpy array to a file
# allow_pickle=False prevents numpy from trying to save object arrays (dtype=object) using pickle
np.save(file=local_path, arr=python_val, allow_pickle=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably leverage typing.Annotated to offer an escape hatch in case the user wants to pickle object arrays (with all the risks/caveats). Not for this PR though.

@samhita-alla samhita-alla merged commit 771aa8a into master May 28, 2022
eapolinario pushed a commit that referenced this pull request Jun 17, 2022
* precommit

Signed-off-by: Samhita Alla <[email protected]>

* fix failing tests

Signed-off-by: Samhita Alla <[email protected]>
@eapolinario eapolinario mentioned this pull request Jun 17, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants