[IPython-dev] thanks for outlining the architecture:

Matthias BUSSONNIER bussonniermatthias at gmail.com
Fri Oct 18 04:07:37 EDT 2013

Le 18 oct. 2013 à 03:54, Joshua Donnelly a écrit :

> I learnt a few more things, and made some progress, mainly
> SOME GOOD NEWS is back on dev master, with that ipython_notebook_config.py line removed
> as you suggested... "C:\A\Y\Canopy\Env\User\python.exe" -m IPython notebook --profile=node
> NOW starts the notebook server!! (repeated below with notes, since the test code
> ["hello from "," to IPython Notebook"].join("Node.js") just runs with errors)
> I cc'd to ipython-dev at scipy.org but no response,

That happen, you can also reply only to dev-list, I'm on it and will continue to respond. 
activity on list comes and goes. maybe the already started discussion and long mail 
saved some peoples.

> Still stuck at Hello World (from a browser or node context with or without sockets)
> but that's okay for now, thanks so much for your replies (re time constraints
> don't worry about a reply here, I will try to catch up with you on the public 
> Q&A session if that eventuates) and will start just posting to  ipython-dev at scipy.org
> True, I don't need a node kernel (but the code there would provide a starting point),
> to make the simplest node or browser (sockets or no sockets) client script that talks to ipython.  
> ie. "ipython hello world" from IE6, node.js, or chrome canary -- any of those would be a good start 

(I would give up IE6 for now)

> There we're some questions about what I was doing in your last email, the
> stuff below answers those mainly, 
> (Answer) RE: Are you trying to make an In-Browser js kernel like http://nbviewer.ipython.org/5632595? No
> (Answer) RE: why "python.exe -m IPython" and not "python.exe ipython" ? I'm just trying to do what works.

There should be ipython.exe entry point (usually)

Can't tell you exactly haven't use windows in years.

> (Answer) RE: why are you editing the templates? I am editing the templates because that is the true source of the notebook html page, no? 

Yes but you shouldn't have to edit that to inject stuff, (but it is true it is easier)

> (Answer) RE: url rewriting? The url rewriting i was referring to was the static_url() calls and MathJax shenanigins, where
> the server is required to merge files from multiple "static" locations… 

Don't try to mess-up with mathjax, it works without it. 
as for the static_url() it is mostly use on server side when IPython is runned under a prefix. 
usually it only append /static/ at the beginning of url relative to root. 
The merging of static dir is a convenience, it is *just* a search path.

> I was pleased to hear about all those kernels, and wanted to know how to get them all running at once and how to reference a particular on in a notebook cell?
> would it be as easy as saying "language":"ruby" , in a ipynb cell. I mean the notebook select menu doesn't have options for them. Is there a git branch that includes them all for use/testing? as they don't appear to be in the main dev repo, maybe they are just floating around out there (if I search for "Julia" in C:\A\Y\IPY it doesn't show any files) and so far I haven't seen any of the extra kernels working, and trying to do so, has not been easy or fun.

You cannot on a per cell basis, and we don't have any short term, nor long term plan to add this on a per cell basis.
We will add ways to do that on a per-notebook basis, but not yet. 

Right now, you have to run many server, each 'bind' to a language. 

if you install julia you can do in Julia:

Julia> Pkg.add("IJulia")

and it will download lot of stuff, install a python profile. 
then you can actually start IPython-with-julia-kernel with 
$ ipython notebook --profile=julia

you can also do 

$ gem install iruby
$ iruby notebook 
under the hood it does `ipython notebook --profile=ruby`

In best cases it should work out of the box, but theses are both pretty recent projects.

> which is like wow, that's REALLY cool,
> how does one reference a target language/kernel in myfile.ipynb cell? 
> can they all be running at once? or is it just going to use the one
> specified at  -m IPython notebook --profile=xxxx for everything

Yes for now, it is on a per profile

> {
>      "language": "python",
>      "metadata": {},
>      "outputs": [ …

The language will be moved at a top level key soon. 
> maybe python is following the of the folder path (case sensitive like unix not windows)
> C:\A\Y\IPY\IPython that was made when I cloned the repo. -m is not my choice
> it just seems to be what works since IPython is a pure script and not an executable.

python.exe -m 
Run the module, but there should be a IPython entry point installed on windows
you shouldn't have to run the module but if it works...

> I had the command: 
> "C:\A\Y\Canopy\Env\User\python.exe" -i "C:\A\Y\Canopy\Env\User\Scripts\pip-script.py" install -e ".[notebook]"
> that I thought installed and symlinked ipython
> SOME GOOD NEWS is back on dev master, with that ipython_notebook_config.py line removed
> as you suggested... "C:\A\Y\Canopy\Env\User\python.exe" -m IPython notebook --profile=node
> NOW starts the notebook server!!

> _______________________________________________________________
> C:/Users/Administrator/.ipython/profile_node/ipython_notebook_config.py
> _______________________________________________________________
> # Configuration file for ipython-notebook.
> c = get_config()
> c.SubprocessKernelManager.kernel_launch_program = ['node','C:/Users/Administrator/node-kernel/kernel.js','{connection_file_name}']
> c.Session.key=''
> ________________________________________________________________

Sorry my fault I read too fast, and mixed and match old and new config:

try the following

# Configuration file for ipython-notebook.
c = get_config()
c.KernelManager.kernel_cmd = ['node','C:/Users/Administrator/node-kernel/kernel.js','{connection_file}']

Usually the
 c.XxxxxxYyyyy.mmmm_nnnn =
should already exist in the file and just be commented.

> and at least the test code shows something...
> ["hello from "," to IPython Notebook"].join("Node.js")
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-1-9dad664227a0> in <module>()
> ----> 1 ["hello from "," to IPython Notebook"].join("Node.js")
> AttributeError: 'list' object has no attribute 'join'

Seeing a python traceback hint that you are using a python kernel above instruction should fix that.

> _________________________________________________________________
> (Answer) RE: why are you editing the templates? I am editing the templates because that is the true source of the notebook html page, no? 
> (Answer) RE: url rewriting? the url rewriting i was referring to was the static_url() calls and MathJax shenanigins, where
> the server is required to merge files from multiple "static" locations... 
> i did a little test and writting plain href="./static/yes.htm" file references are easier now
> (once one understands what ipy is doing, which I don't) 

Basicaly everything in notebook-webserver-search-path is served under ./static/*.
it is slightly more complicated, but for a first approach it should be ok/

> _________________________________________________________________________
> C:\Users\Administrator\.ipython\profile_default\static\user_hello.htm
> C:\A\Y\IPY\IPython\html\static\yes.htm
> <h1>{{static_url("hello.htm") }}</h1>
> <br><a href={{static_url("user_hello.htm") }} >./static/user_hello.htm ~ via static_url()</a>
> <br><a href="./static/user_hello.htm"} >./static/user_hello.htm</a>
> <br><a href="./static/yes.htm"} >./static/yes.htm</a>
> _________________________________________________________________________
> ===============================================================================
> Trying to make https://github.com/minrk/profile_jskernel work:
> instructions "the run a javascript kernel in-browser instead of remote via websockets, just clone this repo into your IPython directory, and use it with
> ipython notebook --profile jskernel"
> which also the nb file, also at http://nbviewer.ipython.org/5632595 
> which I saved as"C:\A\Y\IPY\examples\notebooks\JSS.ipynb" and ran 
> python -m IPython notebook --profile=jskernel
> which is quite different than the "ipython notebook --profile jskernel" command given at  minrk/profile_jskernel github 
> which will not work on windows since there are exactly zero exe/cmd/
> and only 1 make.bat file in the main IPY/IPython/ repo cloned from github,
> and the pip ipython notebook install added nothing to the system.path anyway 

So this is weird. It should have I guess.

> the notebook app did open, but not the JSS.ipynb file instead I got a nice web prompt saying "Error loading notebook:An unknown error occurred while loading this notebook. This version can load notebook formats v3 or earlier." someone ought to tell people to save it as utf-8 without a BOM, (and why can't ipython notebook can't handle both?) so then it opens in notebook, and I try Math.random()

We should handle both, but with few windows user, we have few bug report. 
If you can reproduce please open a bug ticket.

> {
>      "cell_type": "markdown",
>      "metadata": {},
>      "source": [
>       "With [this profile](
> https://github.com/minrk/profile_jskernel
> ),\n",
>       "kernel.js is replaced by a simple object that executes javascript in the browser rather than remotely via websockets.\n",
>       "\n",
>       "This is more of a toy / proof of concept than anything."
>      ]
>     },
>     {
>      "cell_type": "code",
>      "collapsed": false,
>      "input": [
>       "Math.random()"
>      ],
>      "language": "python",
>      "metadata": {},
>      "outputs": [
>       {
>        "ename": "NameError",
>        "evalue": "name 'Math' is not defined",
>        "output_type": "pyerr",
>        "traceback": [
>         "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
>         "\u001b[1;32m<ipython-input-1-5edbfbed6442>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mMath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
>         "\u001b[1;31mNameError\u001b[0m: name 'Math' is not defined"
>        ]
>       }
>      ],
>      "prompt_number": 1
>     }
> what's weird about that is 
> "language": "python" shouldn't it be like language:"javascript" since here we are trying 

(no the field will not change, but we are working on that)
Still the traceback is python so you are probably not running the js kernel. But I guess the read me is wrong.

> into your IPython **profile** directory

> to run an in browser javascript kernel, which didn't work anyway so it doesn't matter
> https://github.com/minrk/profile_jskernel/blob/master/static/js/kernel.js
> is 5 months old and maybe it replaces the other "kernel.js" that is in the repo
> at "C:\A\Y\IPY\IPython\html\static\services\kernels\js\kernel.js" but maybe not
> so i will go to "C:\A\Y\IPY\IPython\"
> and C:\Users\Administrator\Downloads\profile_jskernel-master\profile_jskernel-master\static\js\kernel.js
> and try to add that 1 file manually, but I don't see a "C:\A\Y\IPY\IPython\static\" folder so maybe
> it is the one in the user profiles static folder since "profile_jskernel-master" "profile" suggests this may be the place
> "C:\Users\Administrator\.ipython\profile_default\static\"
> and add "js\kernel.js" so there is now a new "js" directoty and a file at:
> C:\Users\Administrator\.ipython\profile_default\static\js\kernel.js 
> and then TASKKILL /F /IM python.exe and then 
> -m IPython notebook --profile=jskernel

if you put it in profile_default, then you should run $ ipython.exe notebook --profile=default 

> which outputs: 
> cwd C:\A\Y\IPY\examples\notebooks
> 2013-10-18 10:33:05.783 [NotebookApp] Using existing profile dir: u'C:\\Users\\Administrator\\.ipython\\profile_jskernel'
> 2013-10-18 10:33:05.801 [NotebookApp] Serving local MathJax from C:\Users\Administrator\.ipython\nbextensions\mathjax\MathJax.js at /nbextensions/mathjax/MathJax.js
> 2013-10-18 10:33:05.841 [NotebookApp] Serving notebooks from local directory: C:\A\Y\IPY\examples\notebooks
> 2013-10-18 10:33:05.841 [NotebookApp] The IPython Notebook is running at: 
> 2013-10-18
>  10:33:05.841 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
> this "C:\\Users\\Administrator\\.ipython\\profile_jskernel" won't exist since it hasn't been created and there are no

that basically would have been created by the the cloning operation, but because of the README typo you cloned it in the wrong place...

> instructions for doing so nothing at https://github.com/minrk/profile_jskernel is workable or easily repeatable for me.
> _______________________________________________________________________
> RE: version:3 of the 
> {
>      "cell_type": "code",
>      "collapsed": false,
>      "input": [
>       "samsungData['activity'].value_counts()"
>      ],
>      "language": "python",
>      "metadata": {},
>      "outputs": [
>       {
>        "output_type": "pyout",
>        "prompt_number": 14,
>        "text": [
>         "laying      1407\n",
>         "standing    1374\n",
>         "sitting     1286\n",
>         "walk        1226\n",
>         "walkup      1073\n",
>         "walkdown     986"
>        ]
>       }
>      ],
>      "prompt_number": 14
>     }

> I guess there were design decisions that ended up using all this extra clutter 
> for storing strings in arrays, with all of them ending in \n except for the last,

This is optional, you can store only one string instead of a list of string. 
List of string are just nice for version control.

> having to include "metadata": {} empty objects,

Are not always empty, but some processing operation are **much** more painful if the field does not exist as you alway have to check 
for its existence.

>  and others like "language": "python", 
> which would just be the default, all the double quotes around property values are not
> required by javascript (but are a historic cruft left over from douglas crockford being too
> lazy when he drafted the json spec, json5 would be lighter and easier to read, but I don't
> know if your python json.parser could handle plainer object literals {a:1, b:2, c:true, etc:null}

ipynb are not read only by python and js, so we use default json writer, with just a few options.

> either
> something like text:'line0\n\line1\nline2' could have worked equally as well but whatever is working 
> now is best.

Both word at load time

> And why is "prompt_number": 14 in there twice,
technically there is output prompt number and input prompt number, but most of the time they should match, it is true.

> the output prompts are refreshed each time a new kernel starts or a command is run (massive overuse of the word kernel).

Here I'm lost in what you are trying to show/ask and why there is a overuse of "kernel".


More information about the IPython-dev mailing list