Closed cuibonobo closed 6 years ago
Hi @cuibonobo : thanks for trying this out, sorry for the problems :( It sounds like you are try to use an old version of Stencila Desktop with a newer version of the Python package. We've made some changes to the API that the two use to talk to each other, including adding a ticket for additional security.
We're planning on releasing a new, stable desktop version in a few weeks. But in the meantime, examples using the latest builds are available via http://builds.stenci.la/stencila/. You can connect these examples to the latest version of the Python package (I just made a couple of updates to ensure this works) by running it locally:
$ pip install --user https://github.com/stencila/py/archive/master.zip
$ python -m stencila
Host has started at: http://127.0.0.1:2000/?ticket=R3hwrI204ZNS
Use Ctrl+C to stop
And then pasting that url, including the ticket, into the 'hosts' panel in the user interface (accessible via the button in the bottom right corner) and creating a new Python cell e.g.
Let me know if that works for you, or if I can assist with anything else.
Aha! What a cool way to do testing!
I've done the above but it won't let me add a host. My console says:
Failed to load http://127.0.0.1:2000/?ticket=MFjbehplXLzf: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://builds.stenci.la' is therefore not allowed access.
It seems like if the server that's being created with python -m stencila
adds Access-Control-Allow-Origin: *
to its headers this could work for me.
Instead of using Access-Control-Allow-Origin:*
which is dangerous, we are using Access-Control-Allow-Origin:<origin>
if origin is 127.0.0.1
, localhost
, or *.stenci.la
. See https://github.com/stencila/py/blob/master/stencila/host_http_server.py#L208.
But I chaged that line a few days ago to allow *.stenci.la
(instead of open.stenci.la
). So wondering if you have the most recent version.
Nice! I updated to the latest version and I'm now able to add hosts. I'm still having trouble though. Even though the PythonContext appears in the sidebar, it seems like there is still an API mismatch.
The Javascript is sending the following request body:
{code: "import sys↵↵sys.ver", inputs: {}, exprOnly: false}
...but then the response is a 500 error with the following body:
Traceback (most recent call last):
File "C:\Users\jgarcia\AppData\Roaming\Python\Python36\site-packages\stencila\host_http_server.py", line 185, in handle
response = method(request, *args)
File "C:\Users\jgarcia\AppData\Roaming\Python\Python36\site-packages\stencila\host_http_server.py", line 330, in put
to_json(self._host.put(name, method, kwargs)),
File "C:\Users\jgarcia\AppData\Roaming\Python\Python36\site-packages\stencila\host.py", line 192, in put
return func(**kwargs)
File "C:\Users\jgarcia\AppData\Roaming\Python\Python36\site-packages\stencila\python_context.py", line 361, in executeCode
return self.execute(*args, **kwargs)
TypeError: execute() got an unexpected keyword argument 'exprOnly'
Thanks for your patience! Things are unstable right now due to changes in the API - but it's great having someone like you willing to test things out despite the :bug:s.
I've made that fix and pushed it to master, so you could do a git pull
and try again if you like. You might like to try the Jupyter notebook example which is also fixed now (you will have to type a space or something in a cell to re-execute the code:
Yeah, I figured things would be a little unstable, but it's a cool project which is why I'm sticking around. 😀
I don't see any new commits on master! Maybe you pushed somewhere else haha
Arrrgh, you are right, I hadn't pushed. Done now: https://github.com/stencila/py/commit/ec1f6cbbd485b6ed3b4db741263c89cf07c710dd
That did it!
Thanks for your help!
Great! Great thanks again for your patience and please check back in a little while when things are a bit more stable (next major release of Stencila Desktop is targeted for 1 month from now).
I've been trying to get the Python examples in the 'Stencila Documents` guide to run, but haven't had luck yet. There are 2 problems so far:
py.json
is never run because peer discovery is consistently failing. There is nothing listening on those ports when I start Stencila.py.json
manually ("C:\Users\jgarcia\AppData\Roaming\Python\Python36\site-packages\stencila\host.py"
), instead I get the following errors in my console:Indeed, if I visit
http://127.0.0.1:2000
in my browser I get anHTTP ERROR 403
. After looking athost_http_server.py
I realized that I needed to supplyticket
in the query string. Once I did that I could get a200
response, but thediscoverPeers()
method inHost.js
doesn't expect to know a ticket value, so I guess I'm at a loss for how this is supposed to work.