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

feat: WASM both node and es6 and version bump to 0.0.5 #4601

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ Javascript bindings for [VowpalWabbit](https://vowpalwabbit.org/)
|----------|----------|----------|
| 0.0.3 | 9.8.0 | wasm_v0.0.3 |
| 0.0.4 | 9.8.0 | wasm_v0.0.4 |
| 0.0.5 | 9.8.0 | wasm_v0.0.5 |

## Documentation

[API documentation](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.4/wasm/documentation.md)
[API documentation](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.5/wasm/documentation.md)

## Examples and How-To

`@vowpalwabbit/vowpalwabbit` can be used both in nodejs and in ES6 environments.

### How-To include the dependency and initialize a Contextual Bandit ADF model

Full API reference [here](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.4/wasm/documentation.md#CbWorkspace)
Full API reference [here](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.5/wasm/documentation.md#CbWorkspace)

Require returns a promise because we need to wait for the WASM module to be initialized before including and using the VowpalWabbit JS code

A VW model needs to be deleted after we are done with its usage to return the aquired memory back to the WASM runtime.

#### NodeJS environments

```(js)
const vwPromise = require('@vowpalwabbit/vowpalwabbit');

Expand All @@ -28,7 +35,18 @@ vwPromise.then((vw) => {
});
```

A VW model needs to be deleted after we are done with its usage to return the aquired memory back to the WASM runtime.
#### ES6 environments

```(js)
import { vwPromise } from '@vowpalwabbit/vowpalwabbit';

let vwModule = await vwPromise;

let model = new vwModule.CbWorkspace({ args_str: "--cb_explore_adf" });
model.delete()
```

The rest of the examples are shown with the nodejs `require` but the rest of the API usage is identical for both environments.

### How-To call learn and predict on a Contextual Bandit model

Expand Down Expand Up @@ -150,7 +168,7 @@ A model can be loaded from a file either during model construction (shown above)
}
```

### How-To log examples into a file or stringify examples for user-handled logging
### How-To log examples into a file or stringify examples for user-handled logging (currently available for nodejs environments only)

A log stream can be started which will create and use a `fs` write stream:

Expand Down Expand Up @@ -182,7 +200,7 @@ There is also the option of stringifying an example for user-handled logging:
let cbAsString = CBExampleToString(example);
```

Synchronous logging options are also available [see API documentation](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.4/wasm/documentation.md#VWExampleLogger)
Synchronous logging options are also available [see API documentation](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.5/wasm/documentation.md#VWExampleLogger)

### How-To train a model with data from a file

Expand Down Expand Up @@ -231,7 +249,7 @@ catch (e)

### How-To use a generic VW model (non Contextual Bandit specific functionality)

Full API reference [here](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.4/wasm/documentation.md#Workspace)
Full API reference [here](https://github.com/VowpalWabbit/vowpal_wabbit/blob/wasm_v0.0.5/wasm/documentation.md#Workspace)

#### Simple regression example

Expand Down
11 changes: 6 additions & 5 deletions wasm/developer_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ npm run docs
### Release on npm

1. Update the version in package.json
2. Change all version references in README.md (relative links will be broken until merged to master and the tag is cut)
3. Update the table in README.md to point to latest VW version and tag
4. Commit changes to master
5. Tag the release as `wasm_v.major.minor.patch`
6. Publish to npm `npm publish --access public` (you need to sign into your npm account first and have access to the vowpalwabbit organisation)
2. Run `npm run docs` and check in the new `documentation.md` if it has changed
3. Change all version references in README.md (relative links will be broken until merged to master and the tag is cut)
4. Update the table in README.md to point to latest VW version and tag
5. Commit changes to master
6. Tag the release as `wasm_v.major.minor.patch`
7. Publish to npm `npm publish --access public` (you need to sign into your npm account first and have access to the vowpalwabbit organisation)
Loading