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
Html notebook #179
Html notebook #179
Conversation
…t code really is as simple as I've made it...
… turn escaped terminal commands (colors) into html. Fancy regexps!
404 for the JS files
…ory / notebook behavior is supported
…anage ondeck message
…es -- also useful for cleaning up messages
… I need to enable the full object_info_request before this is satisfying
…ckend breaks with history still...
… events to make it more consistent
queue up messages on the comet side to make execute ok
… will actually display! Also, tweaked the styling
Oops, forgot to preview my last comment. The patch should look like this: mvoorhie@virgil:~/Cpackages/iPython/ipython$ git diff diff --git a/setupbase.py b/setupbase.py index 9d4215d..2530623 100644 --- a/setupbase.py +++ b/setupbase.py @@ -111,7 +111,8 @@ def find_packages(): add_package(packages, 'frontend') add_package(packages, 'frontend.qt') add_package(packages, 'frontend.qt.console', tests=True) - add_package(packages, 'frontend.terminal', tests=True) + add_package(packages, 'frontend.terminal', tests=True) + add_package(packages, 'frontend.html') add_package(packages, 'kernel', config=False, tests=True, scripts=True) add_package(packages, 'kernel.core', config=False, tests=True) add_package(packages, 'lib', tests=True) |
James, Mark's comment is the patch we talked about today right before you left. It would be great if you could apply this little fix soon, to make it easier for others to test your code (which is really, really cool :) |
Thanks Mark, I've added your patch. As for linking the html files, I'm not sure what's the best solution to this. Currently, the html, css, and javascript files are in the same directory as the main module. The module sets its own basepath using its main.file, and looks for the path from there. Evidently, this does not work with the install script. Since I'm not familiar with the distutils and setup, can someone suggest the best way to make /usr/local/bin/ipython-http work directly? |
I can't help right now (leaving town shortly) but if you don't get help separately, I'll explain how to do it after the weekend... |
…re to get html and js files
I think the page should be named "IPython session" instead of "Ajax Test". It could use the project's logo as favicon too, or maybe just [I]: Besides, I think the frontend should be named ipython-webnb instead of ipython-http, per the discussion that took place on the dev list a few days ago. |
…ck bug in messages, and added a favicon
…sleep;print;sleep pattern
Hey James, this looks great, and I really want to get it merged in sooner rather than later, so you don't have to work in isolation for very long. A few small notes from random testing:
#----------------------------------------------------------------------------- # Copyright (c) 2010, IPython Development Team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- in the files as you have a chance. It's best that these are carried regularly.
http://ipython.scipy.org/doc/nightly/html/development/coding_guide.html#new-files
Note: if you need icons, http://ipython.scipy.org/ipython-icons/ has our current set of icons in png format. We can ask Min for the original svg later. SummaryThis is fantastic work. I'm very, very excited about this, and I hope we can get it merged very soon. Let me know if you want a hand with any of the review items above, and we'll get this in. I'll make a note on the list asking for further review on more web-specific stuff, as I know very little about those architectures. |
Hi Fernando, sys.stdout.write("Hello ") actually work correctly now. As a side effect (feature!) of this reorganization, now graphs are pushed to all web clients, regardless of who made the request. I'll try to get the documentation and unit-testing up to par over the next few days, although I need to get up to speed on Sphinx. |
Hey James, thanks, this looks like good progress. One minor point I failed to notice yesterday: we're trying to use pep-8 names by default, which means calling module files with lowercase only: CometManager.py -> cometmanager.py (I'd actually just call it 'comet.py' for short). the rest of the changes in the last two commits look good. Ping us here when you've completed things and we'll go over it again. |
This is my first round of comment, mostly focusing on the UI.
More comments on the way about the actual code and architecture. Great work though! |
Thanks for the comments. A lot of these features are planned for a full notebook interface, which would allow cell shuffling, grouping, etc. That's probably a big enough merge by itself to be a separate pull request. Let's look through this list:
|
So I suggest in the NB to simply have, without any smarts:
Later, I'd use Ctrl-Return to split up a cell in two, which can be very handy. |
I get the bug in Chrome 7. I will post a screenshot to the list. Also, get a minor issue at the same place with Firefox.
I agree with Fernando about Return = newline, Shift-Return=execute code.
Ahh, maybe something like this:
We should have a keyboard stroke dedicated to this...ctrl-D? command-D on Mac?
Great
Awesome. |
OK, some additional issue:
File "/Users/bgranger/Documents/Computation/IPython/code/ipython/IPython/frontend/html/kernelmanager.py", line 95, in do_POST Looks like simply an import error.
|
James, Brian and I had a long talk about the web architecture and things him and Min are doing on the pyzmq side. The short of it is that in a little while, it will likely be possible to refactor some of your http code to run on top of the Tornado web server (imported from pyzmq). This will give us ssl support, a better async model and better scalability. This is just to give you a heads-up not to worry too much about major work on the http serving part of your code right now. I think if you have a chance to wrap up the various items pointed in this review, we're pretty much ready to merge once those are fixed. Once merged, we can then continue to build on it and later in the month revisit the http serving part of things. But your code as it is, is a great starting point to build on. |
James, I noticed one more problem: if you actually install your branch, then it doesn't work right. I did an install to a temporary throw-away directory, and in the browser I get: XML Parsing Error: no element found Location: http://localhost:8080/notebook Line Number 1, Column 1: while the terminal shows: ---------------------------------------- localhost.localdomain - - [29/Oct/2010 21:16:31] "GET /notebook HTTP/1.1" 200 - ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 57620) Traceback (most recent call last): File "/usr/lib/python2.6/SocketServer.py", line 560, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.6/SocketServer.py", line 617, in __init__ self.handle() File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle self.handle_one_request() File "/usr/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request method() File "/home/fperez/tmp/junk/lib/python2.6/site-packages/IPython/frontend/html/kernelmanager.py", line 60, in do_GET page_text = Template(open(basepath + "notebook.html").read()) IOError: [Errno 2] No such file or directory: '/home/fperez/tmp/junk/lib/python2.6/site-packages/IPython/frontend/html/notebook.html' ---------------------------------------- You may need to play with the data_files and/or package_data (I can't remember precisely which right now, have a look at the distutils docs for both of these flags), because I think the problem is that the js/css code isn't getting put in the installed version. With new code like this, it's always a good idea to test it both from a source tree and from a temporary installation. |
Hey James, Satra made a good suggestion in general, but the html notebook is probably the most critical place to put it in. How about we add a warning at the top of the opening page for now that reads: Since the ZMQ code currently has no security, listening on an external-facing IP is dangerous. You are giving any computer that can see you on the network the ability to issue arbitrary shell commands as you on your machine. Be very careful with this. Hopefully we can remove it soon, but it's probably a good idea to have in there for now. |
How does the sage notebook handle security? very cool! |
What is the status of this pull request? It seems very relevant to our new rewrite of the Sage notebook. |
Unfortunately, I haven't had enough time to develop this further. I would like to get back into it soon though, so please keep watching. I'm planning to move over to tornado as per the suggestions above. |
Several students and I are working on a "single cell Sage notebook" which shares a lot of similarities with your project. At the recent Sage Days 29, I talked a lot with Fernando and others about using the ipython protocol to implement our project. We are implementing our project using uwsgi and flask, so we wouldn't be using websockets, but instead use a database as a huge cache of the requests between the client and server. Anyways, I'm following this and may use or extend the javascript code here as part of our implementation of the messaging spec. We will probably work on this pretty heavily starting in May. |
The html notebook work is being continued in the htmlnotebook branch here: |
Great; thanks! |
Restaure Global configurable
Hi everyone,
I've coded up a preliminary Javascript-based frontend for the new zmq kernel. Fernando helped me get my git set up for this, so a big kudos to him!
I'm new at python setup scripts, but if I did this correctly, you can run this branch with ipython-http. If this did not work, you can try running ipythonhttp.py inside IPython/frontend/html/. As a note, you cannot run the file from the same directory, due to how it extracts the current directory name. Go to IPython/frontend, then run python html/ipythonhttp.py --pylab inline.
As an overview of the architecture:
The HTTP server is just a default BaseHTTPServer, where the BaseHTTPHandler directly hooks into a module-level CometManager object. This object keeps track of any messages the kernel emits, and multiplexes the messages over HTTP to any all clients. The design of IPython.frontend.html.kernelmanager is nearly a direct copy from the qt version. ipythonhttp.py is also a direct copy from the qt.console.ipythonqt. In other words, it is possible to connect the http server to an existing kernel using the exact same commands as in ipython-qtconsole
On the client side, Jquery was used to build most of the javascript objects. Unfortunately, the javascript is poorly tested, and may be fragile. Most of the XREQ and PUB features are supported. Messages on the PUB socket will be displayed by all web clients. This is accomplished with the "Comet" design pattern, where the client opens and maintains a long-living connection to the server in the form of a GET request. The server waits on the kernel for a message, which it immediately sends along. Anything on the PUB socket is transmitted via GET requests, and anything over XREQ is over POST requests. Multi-line inputs are supported with ctrl-enter, with shift-enter to submit. Inline SVGs are supported for pylab inline, and a notebook-like interface for interaction. Tab completion will open a selection window for candidates.
Some known issues:
Major security vulnerability: direct shell access on the internet. Make sure your firewall is secure!
There are no tests for the javascript code
If multiple web clients are connected, message numbers might be messed up
Sometimes, the entry message may disappear without adding another
Some responding "output" messages may get swallowed by the javascript manager (let me know if you can find a reproducible case)
Please give me some feedback on this code!