.. toctree:: :maxdepth: 2 install npm
If grunt doesn’t succeed, the continuous integration tests will fail as well.
Modifying .ad.js files
Files with names which end with
.ad.js are transformed to use AD
primitives when WebPPL is installed.
During development it is necessary to run this transform after any
such files have been modified. A grunt task is provided that will
monitor the file system and run the transform when any
files are updated. Start the task with:
Alternatively, the transform can be run directly with:
The scope of the transform is controlled with the
directive. If this directive appears directly after the
strict' directive at the top of a file, then the whole file will be
transformed. Otherwise, those functions which include the directive
before any other statements or expressions in their body will be
transformed. Any function nested within a function which includes the
directive will also be transformed.
To only run the tests, do:
To reproduce intermittent test failures run the inference tests with the random seed displayed in the test output. For example:
RANDOM_SEED=2344512342 nodeunit tests/test-inference.js
nodeunit can also run individual tests or test groups. For example:
nodeunit tests/test-inference.js -t Enumerate
See the nodeunit documentation for details.
To only run the linter:
For more semantic linting, try:
If the linter complains about style errors (like indentation), you can fix many of them automatically using:
grunt lint --fix --force
To generate a version of WebPPL for in-browser use, run:
npm install -g browserify uglify-js grunt bundle
The output is written to
bundle/webppl.js and a minified version
is written to
To use in web pages:
<script src="webppl.js"></script> <script>webppl.run(...)</script>
We also provide an in-browser editor for WebPPL code.
To check that compilation was successful, run the browser tests using:
The tests will run in the default browser. Specify a different browser
BROWSER environment variable. For example:
BROWSER="Google Chrome" grunt test-browser
Repeatedly making changes to the code and then testing the changes in the browser can be a slow process. watchify speeds up this process by performing an incremental compile whenever it detects changes to source files. To start watchify use:
npm install -g watchify grunt browserify-watch
Note that this task only updates
bundle/webppl.js. Before running
the browser tests and deploying, create the minified version like so:
Packages can also be used in the browser. For example, to include the
webppl-viz package use:
Multiple packages can specified, separated by colons.