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

A proper WASM interface for code execution #1

Open
Carnageous opened this issue Dec 24, 2020 · 1 comment
Open

A proper WASM interface for code execution #1

Carnageous opened this issue Dec 24, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Carnageous
Copy link
Member

Carnageous commented Dec 24, 2020

Code for this issue can be found in the https://github.com/roulzhq/Codebook-runtime-wasm repository. It is documented here just to keep track of the process.

In order to execute Javascript via WASM, we need a proper interface for executing cells. My proposal for this:

  1. The WASM module exposes a function to create a Otto VM for a codebook. This function returns an ID that is then saved in the Angular app.
  2. This ID is then used to execute "commands" on this VM, for example executing code, clearing the VM, restarting or deleting it.
  3. It might also be a good idea to return a js object that represents the VM, but I don't know how suitable that is in terms of implementation. However, this would allow for a clean, object-orientated way to use the VM. I'm thinking of something like
    vm.execute(<code>), vm.clear(). A functional approach will be easier to start with.
  4. The commands should be JSON-based and could look like this:
{
  "CodebookId": string,
  "CellId": string,
  "CommandType": Enum, // Execute, clear, delete etc.
  "Payload": object?, // The code, additional information etc.
}
@Carnageous Carnageous changed the title Support JS code execution A proper WASM interface for code execution Dec 24, 2020
@Carnageous Carnageous self-assigned this Jan 7, 2021
@Carnageous Carnageous added the enhancement New feature or request label Jan 7, 2021
@Carnageous
Copy link
Member Author

Will switch to Pyoride, because it's just great! You can load python packages like numpy and matplotlib, which make Codebook really great.
On the other hand, integrating this properly will be hard: I don't just want to import it as a script in the FE, because I still want a single WASM interface for code execution. I guess I will make an ugly js => codebook WASM => js.pyoride => WASM call until I figure out how to directly call pyoride from wasm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant