These are chat archives for ipython/ipython

1st
Oct 2014
Thomas Kluyver
@takluyver
Oct 01 2014 00:01
is there something special for interact()? Because print() definitely works there.
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:02
yeah but save_changes is called via 'touch' from a widget view
not a widget model.
Thomas Kluyver
@takluyver
Oct 01 2014 00:03
oh, stdout only works if the change comes from a view, not directly from a model?
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:05
exactly. WidgetView.touch calls model.save_changes and passes the callbacks corresponding to the right cell
WidgetModel.save_changes() with no callbacks has no cell to talk to.
Thomas Kluyver
@takluyver
Oct 01 2014 00:06
OK, I see
it certainly seems reasonable to do something with it
though I suspect it would be quite easy to fill up the console with unwanted junk if we just console.log()ed everything
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:08
console output?
Jonathan Frederic
@jdfreder
Oct 01 2014 00:08
terminal*
Thomas Kluyver
@takluyver
Oct 01 2014 00:10
does the kernel know that that stdout isn't going anywhere?
I'm guessing the kernel just sends it, and only the frontend knows that there's nowhere to put it
esp. if there's e.g. a monitoring frontend that should see all stdout
Min RK
@minrk
Oct 01 2014 00:11
the kernel knows that stdout is going to the thing that requested the execution
Jonathan Frederic
@jdfreder
Oct 01 2014 00:11
yes @takluyver
and yes @minrk
Min RK
@minrk
Oct 01 2014 00:12
whoever owns the comm (in this case) is in complete control over where outputs should go
Jonathan Frederic
@jdfreder
Oct 01 2014 00:13
which is the front-end, so you're suggesting it be printed to the js console?
Min RK
@minrk
Oct 01 2014 00:13
We could easily change the default behavior from if no output callback: discard to if no output callback: console.log
I'm not sure that's a good idea, but it would be easy
Thomas Kluyver
@takluyver
Oct 01 2014 00:13
yeah, I guess it would be easy to clutter up the console like that
Jonathan Frederic
@jdfreder
Oct 01 2014 00:14
Let's bring the pager back to life!
(I guess it hasn't really been killed yet)
;)
lol
Min RK
@minrk
Oct 01 2014 00:14
but at the same time, it probably shouldn't be happening, so its presence indicates something is amiss
Thomas Kluyver
@takluyver
Oct 01 2014 00:15
seriously, though, one thing I wonder about is, instead of discarding, keep a rolling buffer of the last 100 lines, say, which you can access in the console if you want to see them
Jonathan Frederic
@jdfreder
Oct 01 2014 00:15
Oh that's a cool idea
Min RK
@minrk
Oct 01 2014 00:16
so instead of logging, save to IPython.ignored_outputs
(or kernel.ignored_outputs, perhaps more logically)
Thomas Kluyver
@takluyver
Oct 01 2014 00:16
all my ideas are :sunglasses:
Jonathan Frederic
@jdfreder
Oct 01 2014 00:16
:horse:
horse ~= donkey
Thomas Kluyver
@takluyver
Oct 01 2014 00:19
that seems a bit nicer than stuffing it all in the console, if you want to look in the console for some other message
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:22
@minrk what do you think is amiss?
Thomas Kluyver
@takluyver
Oct 01 2014 00:25
he's just headed home
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:27
would you guys would like to have some video discussion on this specifically (aside of the dev meeting). I hope to convince you that what we are doing comes naturally from a simple use case.
We could use other :sunglasses: ideas :)
Jonathan Frederic
@jdfreder
Oct 01 2014 00:28
This message was deleted
Thomas Kluyver
@takluyver
Oct 01 2014 00:30
'like' may not be the word, but it's probably a good idea ;-)
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 00:33
gentlemen - got to go see you then
Thomas Kluyver
@takluyver
Oct 01 2014 00:33
very well
have a good evening
what's left of it over east
Jonathan Frederic
@jdfreder
Oct 01 2014 00:35
s/west/east? (or east of where you are now)
I guess west of the pond :)
Thomas Kluyver
@takluyver
Oct 01 2014 00:35
I never said anything wrong
(thanks gitter ;-) )
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:38
So I have fallen down a rabbit hole regarding kernel.js and session.js
Min RK
@minrk
Oct 01 2014 00:39
events?
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:39
I was trying to play around with having the UI for executing things be disabled when the notebook starts, until the kernel is started
And I succeeded with that, but found a whole bunch of edge cases in which you want to know the status of the kernel but don’t have it
So, for example, it seems like Kernel.running is not always correct
Yeah, I’ve been using events
Min RK
@minrk
Oct 01 2014 00:40
there are two separate things to keep track of: the state of the kernel and the state of the connection to the kernel.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:40
Yeah
Min RK
@minrk
Oct 01 2014 00:41
for execution, it's mainly the connection (websocket) that you care about.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:41
Ok
Min RK
@minrk
Oct 01 2014 00:41
channels_started is the relevant event, I think
(not certain)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:42
What is the relationship with session, then? I was under the impression that the session was essentially the connection to the kernel
But all the websocket code is in kernel.js
Min RK
@minrk
Oct 01 2014 00:43
Ah, no. Just another case of horrible names.
Session just contains the relationship between kernel and notebook
execution is all directly through the kernel.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:44
Hmmm
Min RK
@minrk
Oct 01 2014 00:44
Session is only used for "give me the kernel for this notebook"
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:44
I see
Min RK
@minrk
Oct 01 2014 00:45
(and shut it down, etc)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:46
Ok, so I guess there are some violations of abstraction in notebook.js, then, because it has a direct reference to the kernel, rather than getting it through the session
Min RK
@minrk
Oct 01 2014 00:48
Well, sort of. The session is used to find the notebook's kernel. The kernel is then used directly thereafter.
originally, the addition of session eliminated any direct reference from notebook to kernel
but then the notebook was just filled with dozens of this.session.kernel, which was deemed an unnecessary and annoying indirection.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:51
Hmm well it seems like there’s still a bunch of things that use this.session.kernel, and then a few that use this.kernel
Like this.session.rename_notebook(name, path);
Actually the only place that this.kernel is really being used is when code cells are created I think
Min RK
@minrk
Oct 01 2014 00:53
it may have been cleaned up since then - I seem to recall a number of this.notebook.kernel, which would be this.notebook.session.kernel
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:54
After the session successfully starts the kernel, is it necessary anymore?
Because if not, what we could do is create the session and start it, once the kernel is started, save the reference to it in this.kernel, and then delete the session
Min RK
@minrk
Oct 01 2014 00:55
I believe it is only used for starting and shutting down (actually removing the kernel, not kill/restart)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:55
Which would probably be a bit clearer in terms of what is supposed to be used
Oh, shutting down, right
The session does have methods for restart and kill too, though
Min RK
@minrk
Oct 01 2014 00:56
it also gets used when switching kernels, because that means starting a new kernel and associating it with a notebook.
I believe session also has to be notified of notebook renames
Session.restart and kill should probably be removed
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:57
nod
Ok, I see, so really the only things where it’s actually necessary are when accessing one of the api/whatever URLs
?
Min RK
@minrk
Oct 01 2014 00:58
yes
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:58
Got it
Min RK
@minrk
Oct 01 2014 00:58
the objects in /services/foo are just JS wrappers around the REST APIs
(+ ws for kernels)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 00:59
Ok
Min RK
@minrk
Oct 01 2014 00:59
we actually want to do the same with notebooks
(come to think of it, perhaps we should have done that with kernelspecs)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:00
The same with notebooks… having them be a wrapper around a REST API?
Makes sense for kernelspecs
Min RK
@minrk
Oct 01 2014 01:01
Notebook.js is one object that does two things: 1. wrap the REST API for saving/checkpointing/etc. 2. draw stuff on the page
I think we want to take the wrapper for the REST API out, and make it a simple object in /services/contents
basically, remove all of the methods that make AJAX calls, and put them in another object that a UI notebook has
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:03
Ah, yeah, that makes sense
Yeah
Min RK
@minrk
Oct 01 2014 01:03
basic model-view separation kind of stuff
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:03
Yup
Well I think I will try to separate kernel.js and session.js a bit more cleanly
Min RK
@minrk
Oct 01 2014 01:04
but if you want to put together a proposal (or better yet PR) to clean up those two, especially thinking carefully about the events, that would be great
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:04
Sure, yeah
Min RK
@minrk
Oct 01 2014 01:04
awesome, thanks
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:04
And yeah I think the events are kind of messy currently
Min RK
@minrk
Oct 01 2014 01:04
very much so
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:05
Ok, so one last question about sessions vs kernels
When you start the session, that starts the kernel
And you can use the session to remove the kernel
What is supposed to happen when the kernel gets removed some other way, that the session doesn’t know about?
Min RK
@minrk
Oct 01 2014 01:06
Then the session is in an inconsistent state
It associates a notebook with a kernel that doesn't exist, but it doesn't know that it doesn't exist anymore
Thomas Kluyver
@takluyver
Oct 01 2014 01:06
we actually ran into that one
some of the tests were doing that
Min RK
@minrk
Oct 01 2014 01:06
if I recall correctly, when you try to get that session, it will find out that its kernel doesn't exist, and then delete itself
Thomas Kluyver
@takluyver
Oct 01 2014 01:06
yep
Min RK
@minrk
Oct 01 2014 01:07
effectively, deleting a session's kernel deletes the session
but the session doesn't know it's been deleted until the next time it is requested
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:07
Ok
Min RK
@minrk
Oct 01 2014 01:07
I think @takluyver fixed a bug in that logic recently
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:07
Yeah, it seems like this is also an issue when you shutdown the kernel from the dashboard while it’s open in another tab
Min RK
@minrk
Oct 01 2014 01:07
yes, I think that's probably true
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:07
At least I think that’s what’s going on
Min RK
@minrk
Oct 01 2014 01:07
a lot is broken when a notebook is open twice
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:09
When a kernel is shutdown, does it not send messages to everything that is connected to it?
Or does it and that’s just not currently handled by the notebook interface?
Min RK
@minrk
Oct 01 2014 01:10
I don't think it's handled by the notebook. Probably could be.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:10
Ok
Min RK
@minrk
Oct 01 2014 01:11
I guess if a notebook finds out that the session was deleted, it could just make a new one.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:12
That seems reasonable
Min RK
@minrk
Oct 01 2014 01:12
doesn't make much sense to do anything else
other than enter a "no-kernel" state
which we haven't implemented yet
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:12
Yeah
I think that is probably really what is necessary
Currently there’s “dead kernel"
Min RK
@minrk
Oct 01 2014 01:12
we keep saying that...
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:12
And “websockets closed"
And “session not started"
Which it seems like are kind of all equivalent to “no kernel”?
Min RK
@minrk
Oct 01 2014 01:13
to varying degrees, yes
as far as UI goes, yes. There's a distinction between 'a kernel exists' and 'I am connected to it'
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:14
Hmm, true
Min RK
@minrk
Oct 01 2014 01:14
but the former doesn't matter to cell.execute
it only matters if you have a connection
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:14
Where does the distinction matter?
Min RK
@minrk
Oct 01 2014 01:14
I guess it matters in setting up the connection...?
not sure
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:14
And can you know that a kernel exists but that you are not connected to it?
Min RK
@minrk
Oct 01 2014 01:15
e.g. "I need a connection" might start with "create a new kernel", or it might start with "I already have a kernel, just reconnect"
yes, you can know that the kernel exists without being connected
connected meaning websockets, that is. You can find kernels with REST, which will only show you kernels that are running
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:16
I see
Ok
Cool
Ok, I am going to go fiddle around with stuff
Min RK
@minrk
Oct 01 2014 01:17
I need to do some dishes before dinner, but I look forward to your PR!
Jessica B. Hamrick
@jhamrick
Oct 01 2014 01:17
:)
Matthias Bussonnier
@Carreau
Oct 01 2014 16:07
do we have design meeting today ?
Min RK
@minrk
Oct 01 2014 16:11
not that I'm aware of. I think there's one Friday
Jessica B. Hamrick
@jhamrick
Oct 01 2014 17:46
@minrk #6586
Min RK
@minrk
Oct 01 2014 17:50
@jhamrick hooray!
Jessica B. Hamrick
@jhamrick
Oct 01 2014 17:54
I think kernel.js could still benefit from some rearranging of the functions, just to make the code easier to read
But I decided not to do that now because it would make the pull request horrendous to review
It’s probably already a little hard to follow, sorry about that
Min RK
@minrk
Oct 01 2014 17:55
That makes sense. No worries, it looks carefully done, thanks for doing that.
Jessica B. Hamrick
@jhamrick
Oct 01 2014 17:57
No problem!
I am happy that I’m finally getting familiar enough with the ipython code to make these types of contributions :)
I couldn’t find any case in which Kernel.start was actually called with parameters — was that a remnant of how starting the kernel used to work?
Or is that something that should still be there?
Thomas Kluyver
@takluyver
Oct 01 2014 18:09
I think now we start the session; that creates the kernel server side, and the frontend just connects to it
Min RK
@minrk
Oct 01 2014 18:35
I believe that was added for customization done in the Sage single-cell server
Jessica B. Hamrick
@jhamrick
Oct 01 2014 18:43
Ah ok
I’ll add it back in then with a comment as to why it’s there
Matthias Bussonnier
@Carreau
Oct 01 2014 19:00
@jhamrick better than a comment : A test :-)
Jessica B. Hamrick
@jhamrick
Oct 01 2014 19:01
Truth
Jason Grout
@jasongrout
Oct 01 2014 19:52
yes, I think it was something we needed for the sage cell server
thanks for keeping it in :)
Kyle Kelley
@rgbkrk
Oct 01 2014 20:00
I used Kernel.start for hackery
I don't even know how it normally gets used
Min RK
@minrk
Oct 01 2014 20:50
Kernel can be used without Session, e.g. in applications that don't use notebooks.
Thomas Kluyver
@takluyver
Oct 01 2014 22:23
@ellisonbg @jdfreder we're going to cut 2.3 pretty soon - is there anything else you're aware of that should be backported?
anyone else who's reading this, you're also welcome to suggest things
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 22:33
jon says no
SylvainCorlay @SylvainCorlay cannot put thoughts in other people' s mind
Sylvain Corlay
@SylvainCorlay
Oct 01 2014 22:34
(I was trying /jon)
Thomas Kluyver
@takluyver
Oct 01 2014 22:38
:P
neat, there's a /ban option
Jonathan Frederic
@jdfreder
Oct 01 2014 22:49
test