Open sergeiwallace opened 7 years ago
I reproduced this issue using the Docker node container:
root@057cd7d5ab79:~/.webppl/node_modules/webppl-agents# webppl --require webppl-dp --require . tests/tests.wppl
/root/.webppl/node_modules/paper/dist/paper-node.js:10835
document = jsdom.jsdom('<html><body></body></html>'),
^
TypeError: jsdom.jsdom is not a function
at new <anonymous> (/root/.webppl/node_modules/paper/dist/paper-node.js:10835:19)
at Object.<anonymous> (/root/.webppl/node_modules/paper/dist/paper-node.js:33:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/root/.webppl/node_modules/webppl-agents/src/visualization/gridworld.js:1:75)
I was able to fix this issue by editing paper-node.js. I replaced lines 10832-10839 with:
var jsdom = require('jsdom');
const { JSDOM } = jsdom;
domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml;
Canvas = require('canvas');
const { document } = (new JSDOM('')).window;
global.document = document;
window = document.defaultView;
navigator = window.navigator;
HTMLCanvasElement = Canvas;
Image = Canvas.Image;
And line 11471 with
canvas = new Canvas.Canvas(width, height);
Running webppl --require webppl-dp --require webppl-agents tests.wppl
now yields
{
utils: [ true, true ],
makeGridWorldMDP: [ true ],
makeBanditPOMDP: [ true ],
makeGridWorldPOMDP: [ true ],
makeMDPAgent: [ true ],
makePOMDPAgent: [ true ],
simulateMDP: [ true ],
simulatePOMDP: [ true ],
gridworldViz: [ true ],
extend: [ true ],
getMarginalObject: [ true ],
makeBanditStartState: [ true ],
makeBanditAgent: [ true ],
inferBandit: [ true ],
makeRestaurantSearchPOMDP: [ true ],
getRestaurantHyperbolicInfer: [ true ]
}
as desired.
I have installed the dependencies and have gotten the webppl test to work, but unfortunately the webppl-agents test is failing for me (on Windows). When I run the test, I get the error:
Looking around on other threads, there appears to be a dependency issue with paper and jsdom, but I haven't been able to get a handle on it. Any thoughts?