burn icon indicating copy to clipboard operation
burn copied to clipboard

xtask/Add rustwasm task

Open Luni-4 opened this issue 1 year ago • 5 comments

Pull Request Template

Checklist

  • [x] Confirmed that run-checks all script has been executed.
  • [x] Made sure the book is up to date with changes in this PR.

Related Issues/PRs

Provide links to relevant issues and dependent PRs.

Changes

This PR fixes #851

Testing

Describe how these changes have been tested.

Luni-4 avatar Nov 28 '23 12:11 Luni-4

@antimora

I need your help because I think I'm doing something wrong. I get the following error running cargo xtask dist

[2023-11-28T10:06:50Z INFO  xtask::runwasm] Generating package...
[2023-11-28T10:06:50Z INFO  xtask::runchecks] rustup target add wasm32-unknown-unknown


info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
[2023-11-28T10:06:50Z INFO  xtask::runwasm] Building Non-SIMD version of wasm for web...
Error: failed to parse manifest: /home/burn/Cargo.toml
Caused by: failed to parse manifest: /home/burn/Cargo.toml
Caused by: TOML parse error at line 1, column 1
  |
1 | [workspace]
  | ^
missing field `package`

Error: cargo command failed

Is it related to xtask-wasm?

Luni-4 avatar Nov 28 '23 12:11 Luni-4

Burn is setup as a workspace, and you're using wasm-pack, which led me to this possibly relevant issue.

AlexErrant avatar Nov 29 '23 19:11 AlexErrant

@AlexErrant

I've used wasm-pack because of this script https://github.com/Tracel-AI/burn/blob/main/examples/image-classification-web/build-for-web.sh I do not know which command I should use to build the package otherwise

Luni-4 avatar Nov 29 '23 21:11 Luni-4

I've reviewed the work in progress and believe it will require additional time to be properly fixed.

I'm not sure if you have considered integrating xtask directly under example/image-classifier-web, which, in my opinion, seems to be the most appropriate approach. For the task at hand, I suggest relying on xtask-wasm. The xtask under each example would essentially serve as a driver, a thin wrapper, instead of incorporating the logic into the root's xtask. This approach would ensure each example remains self-contained, primarily leveraging the logic from xtask-wasm.

antimora avatar Nov 30 '23 20:11 antimora

@antimora

My initial idea was to create a script which could be used for all our examples, but more generally, for wasm applications. That would also provide a general-purpose mechanism, that is why I've discarded the integration of xtask-wasm in each example. That could also lead to a bunch of duplicated code and difficulties in maintaining these examples if new code is added.

Luni-4 avatar Nov 30 '23 20:11 Luni-4

I'll close it for now since the approach will be different a little bit. I'll try to reuse code from it.

antimora avatar Jan 29 '24 19:01 antimora

Yes, sorry for giving up this PR, busy times. You can reuse my code without any problem!

Luni-4 avatar Jan 29 '24 21:01 Luni-4