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

Fixing np array dumping #599

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

ilongin
Copy link
Contributor

@ilongin ilongin commented Nov 14, 2024

Fix for dumping np array into SQLite as current json lib doesn't work well with the object type np arrays

@ilongin ilongin marked this pull request as draft November 14, 2024 14:22
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.87%. Comparing base (ba9c581) to head (41cddc2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/datachain/sql/sqlite/types.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #599      +/-   ##
==========================================
- Coverage   87.88%   87.87%   -0.01%     
==========================================
  Files         100      100              
  Lines       10011    10015       +4     
  Branches     1357     1358       +1     
==========================================
+ Hits         8798     8801       +3     
  Misses        871      871              
- Partials      342      343       +1     
Flag Coverage Δ
datachain 87.81% <60.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@ilongin ilongin linked an issue Nov 14, 2024 that may be closed by this pull request
Copy link

cloudflare-workers-and-pages bot commented Nov 14, 2024

Deploying datachain-documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: 41cddc2
Status: ✅  Deploy successful!
Preview URL: https://444ca950.datachain-documentation.pages.dev
Branch Preview URL: https://ilongin-598-fix-np-array-dum.datachain-documentation.pages.dev

View logs

Comment on lines 45 to 47
if np.issubdtype(arr.dtype, np.object_):
# orjson cannot parse arrays with object subtype
return json.dumps(arr.tolist(), default=_json_serialize)
Copy link
Member

Choose a reason for hiding this comment

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

orjson also supports default=.... See https://github.com/ijl/orjson#default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tnx, added it instead using json.

@ilongin ilongin marked this pull request as ready for review November 15, 2024 09:02
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.

Fix adapting np array before inserting into SQLite
2 participants