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

parser.setReadtable is not a function (Jupyter) #41

Closed
tbenst opened this issue Sep 12, 2016 · 10 comments
Closed

parser.setReadtable is not a function (Jupyter) #41

tbenst opened this issue Sep 12, 2016 · 10 comments

Comments

@tbenst
Copy link

tbenst commented Sep 12, 2016

I'm attempting to add webppl to a (python) Jupyter notebook using an admittedly hacky method.

webppl-jupyter

Unfortunately I get the following error from webppl: TypeError: parser.setReadtable is not a function. Any thoughts or an alternate suggested method? Thanks!

@tbenst tbenst changed the title Adding to Jupyter parser.setReadtable is not a function (Jupyter) Sep 12, 2016
@longouyang
Copy link
Member

I suspect this is a webppl issue, not webppl-editor; parser.setReadtable is a function inside sweet.js, which is a library that webppl uses.

I'm a little wary of this approach to embedding webppl inside Jupyter; it seems like it'd be much cleaner to write a proper Jupyter kernel (though I know that would be more effort)

@tbenst
Copy link
Author

tbenst commented Sep 16, 2016

Just took a stab at this. Tried this node.js kernel in docker using this Dockerfile but was stymied by an error running node install. Will try again next week

@tbenst
Copy link
Author

tbenst commented Sep 26, 2016

Okay, some progress: can now install webppl and import in jupyter (docker image) Haven't been able to run any webppl code yet (below). Apologies if this is in the documentation somewhere and i missed it

image

@longouyang
Copy link
Member

webppl.prepare takes two mandatory arguments, the compiled code and a continuation, and an optional objects argument:

webppl.prepare(
  compiled, // code
  function(s,x) { }, // continuation that does something with the return val x
  {initialStore: {observedData: [1,2,3]}}) // options; here, I'm setting the initial contents of globalStore

@longouyang
Copy link
Member

(Oh, and btw, this compile/prepare/run stuff isn't documented anywhere yet as far as I know)

@tbenst
Copy link
Author

tbenst commented Sep 27, 2016

Thanks!

Turns out that node.js kernel does not supply cell magics for use with python or another kernel. Seems that Beaker is a better option than jupyter here.

I created a fork of beaker notebook and added webppl as a language: https://github.com/tbenst/beaker-notebook. This is already improved over the previous jupyter example as the compile command happens on the node.js backend.
image

The main limitation is I've yet to implement auto-translation. Any thoughts on how i might include the beaker object in webppl?

Another thought is to add globalStore to the beaker object, and to always initialize webppl with initialStore = beaker.globalStore, and to pass globalStore back after execution & update beaker.globalStore.

@longouyang
Copy link
Member

Nice!

I'm a little unclear on what the interface for the beaker object is. Where is a beaker global variable available -- inside the node.js backend? And what methods do you call on it to make the auto-translation happen?

@tbenst
Copy link
Author

tbenst commented Sep 27, 2016

The beaker object is available in most languages: https://github.com/twosigma/beaker-notebook/wiki/Auto-Translation. The object is global across a notebook. The key feature is you can get and set variables from cells with different languages

@longouyang
Copy link
Member

In this case, I think that your backend code should call prepare with a continuation that uses beaker to do the auto translation on the return value of the webppl program.

@tbenst
Copy link
Author

tbenst commented Sep 27, 2016

cool, got it working:
webppl

should now be usable with this functionality. docker run -it -p 8800:8800 tbenst/beaker-webppl

@tbenst tbenst closed this as completed Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants