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

js target support? #61

Closed
quimt opened this issue Feb 13, 2024 · 4 comments
Closed

js target support? #61

quimt opened this issue Feb 13, 2024 · 4 comments

Comments

@quimt
Copy link
Contributor

quimt commented Feb 13, 2024

Currently attempts to import datamancer when compiling to javascript fail. This is due to the way the package relies on arraymancer:


.nimble/pkgs2/arraymancer-0.7.27-7af6e290b723aead93067e1a52b0b369dd49cfbf/arraymancer/tensor/init_cpu.nim(235, 18) template/generic instantiation of `randomTensorCpu` from here
.nimble/pkgs2/arraymancer-0.7.27-7af6e290b723aead93067e1a52b0b369dd49cfbf/arraymancer/tensor/init_cpu.nim(208, 18) template/generic instantiation of `allocCpuStorage` from here
.nimble/pkgs2/arraymancer-0.7.27-7af6e290b723aead93067e1a52b0b369dd49cfbf/arraymancer/laser/tensor/datatypes.nim(93, 29) template/generic instantiation of `finalizer` from here
.nimble/pkgs2/arraymancer-0.7.27-7af6e290b723aead93067e1a52b0b369dd49cfbf/arraymancer/laser/tensor/datatypes.nim(71, 23) Error: attempting to call undeclared routine: 'deallocShared'

It's a shame that the DataFrame is not available for js. The API is nice and should be available independent of platform-specific concepts like memory management.

@Vindaar
Copy link
Member

Vindaar commented Feb 15, 2024

Hey,

thanks for the nice words and interest!

From my point of view that is a surprising request, but I can see the appeal!

I just had a ~1 hour look and it seems at least basic support is achievable. I don't know how much worse performance is (it will depend). But I've implemented a different backend that simply uses a seq[T] as storage:

#62

Note that I'm not super familiar with the JS backend. So I had to take out a few features (reading CSVs from a file on disk or from a URL), because I'm not exactly sure how to handle these there correctly.

Feel free to check out the related branch and play around with it. That would be much appreciated. And if you have insights into how to improve it / better support some of the missing features, I'm all ears.

@quimt
Copy link
Contributor Author

quimt commented Feb 15, 2024

Will do. File I/O is probably not as important as toDf from seqs and sebsequent mutate, select, and filter operations.

I agree though that a mature web app would want to interact with user-supplied datasets. I'll try to have a look into how Datamancer does this and the various ways user apps might like to interact with CSV.

In my typical use case,, it's probably good enough to embed a dataset using static: and nim-csv to get it in the nim app as a seq of seqs. Since extremely good performance is not likely to be an issue, the datasets involved are usually smaller and don't require much extra space.

@Vindaar
Copy link
Member

Vindaar commented Feb 16, 2024

Cool, thanks for your help!

@Vindaar
Copy link
Member

Vindaar commented Feb 19, 2024

Merging #62 with basic support working for now. I'm going to close the issue, but feel free to open more issues to discuss missing features or whatever else comes to mind!

@Vindaar Vindaar closed this as completed Feb 19, 2024
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

No branches or pull requests

2 participants