These are chat archives for ipython/ipython

4th
Feb 2015
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 00:01
Yes, this could be interesting, an a bit more "magical".
but I don't think that it can work
Thomas Kluyver
@takluyver
Feb 04 2015 00:02
we are really trying to get 3.0 out the door, and while it's technically an easy change to make, traitlets are an important API, and I don't want to rush things like this to push them into the next release.
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 00:03
the reason is that the traitlet object is instantiated before the HasTraits derived class is fully declared. You cannot use its methods
or maybe using some metaclass technique
Min RK
@minrk
Feb 04 2015 00:07
It's a reasonable change. It requires some API discussion, which we can have once 3.0 has shipped.
Thomas Kluyver
@takluyver
Feb 04 2015 00:08
_validate is passed an obj parameter, which appears to be the object owning the traitlet
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 00:08
alright thanks for looking at it anyway.
@takluyver , correct, what I mean is that one cannot do
class Foo(HasTraits):
    bar = Unicode(validate=Foo.baz)
    def baz(self, obj, trait):
        # ...
Thomas Kluyver
@takluyver
Feb 04 2015 00:11
no, I was proposing:
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 00:11
but indeed, one could check if it has a _???_validate method at runtime. during the validation
Thomas Kluyver
@takluyver
Feb 04 2015 00:11
yep, that was the idea
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 00:12
sorry, did not get it right away.
thanks for adding a comment in the PR.
Thomas Kluyver
@takluyver
Feb 04 2015 00:23
no worries
Brian E. Granger
@ellisonbg
Feb 04 2015 00:49
When Fernando comes I can send a bunch back with him.
And also give a bunch to Kyle
To refresh all our supplies.
Doug Blank
@dsblank
Feb 04 2015 01:59
Anybody have any ideas on the problem posted to ipython-dev mailing list? I'm at a loss...
Thomas Kluyver
@takluyver
Feb 04 2015 01:59
which problem was this?
Doug Blank
@dsblank
Feb 04 2015 02:00
The issue about not being able to get kernel_info_reply routed back to right place... just posted today
Thomas Kluyver
@takluyver
Feb 04 2015 02:02
oh, right, hours ago ;-)
ipython-dev lands in the same folder as Github issue notifications, so things get buried fast
Doug Blank
@dsblank
Feb 04 2015 02:02
Yep... it has been a long day for me... on this issue. I'm stuck
Thomas Kluyver
@takluyver
Feb 04 2015 02:03
I think your suspicion about identities may be correct
Doug Blank
@dsblank
Feb 04 2015 02:04
Hmmm, that may mean an encoding issue...
Min RK
@minrk
Feb 04 2015 02:10
@dsblank I started looking into that today, but got sidetracked. I'll have another look tonight. Identities or socket types are usually the issue for lost messages
Doug Blank
@dsblank
Feb 04 2015 02:11
That would be great... I can put the whole Mono/CSharp project in the repo if you want to run it.
console works, and all other messages work in the notebook... just this one I have problems with
Petra Chong
@rekcahpassyla
Feb 04 2015 15:06
Hi- Is there any way to trap the ipython kernel restart event and register a handler to clean up stuff before exit? I have tried atexit.register and signal.signal, but neither of those appear to trigger upon kernel restart.
Min RK
@minrk
Feb 04 2015 17:37
@rekcahpassyla I find that atexit.register does run on kernel restart. signal.signal is less likely, because signals aren't involved in a clean shutdown. How are you setting up atexit?
Petra Chong
@rekcahpassyla
Feb 04 2015 17:38
Hi @minrk - I am doing:
import atexit
atexit.register(bla)
Min RK
@minrk
Feb 04 2015 17:38
in a cell in the notebook?
Petra Chong
@rekcahpassyla
Feb 04 2015 17:39
ah- no, I am running Spyder, and using Ctrl-. to restart the kernel
Min RK
@minrk
Feb 04 2015 17:39
and where are you calling atexit?
Petra Chong
@rekcahpassyla
Feb 04 2015 17:40
A bit more background- I have an object that creates remote processes through a web API. I have a shutdown function, which I want to call when the process exits, and this is what I call atexit.register() with. I am setting atexit.register the first line of my object's constructor
I am currently trying to work out if, because I am on Windows, Spyder is calling the Windows API function TerminateProcess which I understand cannot be trapped
Min RK
@minrk
Feb 04 2015 17:41
It's possible that shutdown on Windows doesn't happen gracefully, let me see if I can check.
Petra Chong
@rekcahpassyla
Feb 04 2015 17:41
Many thanks
Petra Chong
@rekcahpassyla
Feb 04 2015 17:51
OK, I have found that in my version of Spyder, it calls PyQt4.QtCore.QProcess.kill() which definitely uses TerminateProcess. I know that atexit and signal handlers are not called before TerminateProcess.
Min RK
@minrk
Feb 04 2015 17:51
ok
Petra Chong
@rekcahpassyla
Feb 04 2015 17:51
Do I have any other way of trapping a kernel restart event?
Min RK
@minrk
Feb 04 2015 17:51
I don't think IPython does that when it shuts down kernels, so you should probably bring it up with Spyder.
Petra Chong
@rekcahpassyla
Feb 04 2015 17:51
No worries if the answer isn't elementary, i am happy to dig into source code if I have to, just thought I would ask here first.
Min RK
@minrk
Feb 04 2015 17:52
Not really. Terminate events are pretty harsh (same is true on non-Windows)
Petra Chong
@rekcahpassyla
Feb 04 2015 17:52
Thank you @minrk, I shall take it up with Spyder. At least now I know.
Min RK
@minrk
Feb 04 2015 17:53
I would ask Spyder why they are doing a hard shutdown rather than the IPython shutdown request, if that's really what's going on.
I think IPython sends a request, gives the process a window to take itself down, then terminates it if it's taking too long.
Petra Chong
@rekcahpassyla
Feb 04 2015 17:55
The Spyder widgets use PyQt4 and that's what is doing the hard kill- I wonder if I can change the front end. BUt that's Spyder's problem not yours.
Again, thank you for your help!
Min RK
@minrk
Feb 04 2015 17:56
But Spyder uses IPython's qt widget, which has the soft shutdown logic already, which is why I'm not sure why the behavior is different.
Petra Chong
@rekcahpassyla
Feb 04 2015 17:56
I shall take that up with them..
Andreas Klostermann
@akloster
Feb 04 2015 18:00
this may be a stupid question, but is it possible to communicate between javascript in notebook's DOM and the code run in the kernel without involving a widget (which may be destroyed etc)?
Min RK
@minrk
Feb 04 2015 18:01
@akloster yes
Andreas Klostermann
@akloster
Feb 04 2015 18:01
hm
Min RK
@minrk
Feb 04 2015 18:01
The nicest way is to use the Comm API, but that has the destruction/disconnect issue you are referring to in Widgets.
You can, however, use the Javascript API directly to execute code in the kernel, via things like IPython.notebook.kernel.execute("some_python_code()")
Andreas Klostermann
@akloster
Feb 04 2015 18:03
I'm looking into asyncio for widgets/IO in the notebook.... just playing aound though
Andreas Klostermann
@akloster
Feb 04 2015 18:47
got it working, but asyncio's eventloop is using 100% CPU.... probably need a different way of integration
Min RK
@minrk
Feb 04 2015 18:52
The tornado eventloop is already running, you can hook up asyncio to that, I believe
Andreas Klostermann
@akloster
Feb 04 2015 18:55
are the kernels using the Tornado eventloop? I was under the impression that they'd use zmq
Thomas Kluyver
@takluyver
Feb 04 2015 18:56
pyzmq includes a copy of the tornado event loop
Min RK
@minrk
Feb 04 2015 18:56
pyzmq's eventloop is actually the tornado IOLoop
pyzmq only provides a Poller, and plugs that into tornado's IOLoop.
Andreas Klostermann
@akloster
Feb 04 2015 18:57
ok
my current implementation runs the asyncio event loop, and calls do_one_iteration in a loop inside a coroutine
that sort of works, but takes up 100% of the cpu.
asyncio includes an adapter for tornado, so that might be a better idea then
Min RK
@minrk
Feb 04 2015 18:59
Yeah, hooking up event handlers to the already running eventloop is better than pumping one loop from another, if possible.
Andreas Klostermann
@akloster
Feb 04 2015 19:01
the main issue is that asyncio's main loop wants to use some form of "select" to wait for handlers or the completion of timeouts
Thomas Kluyver
@takluyver
Feb 04 2015 19:02
Tornado has some asyncio integration: http://www.tornadoweb.org/en/stable/asyncio.html
I'm not sure if it's possible to hook it up once the event loop is already running
Andreas Klostermann
@akloster
Feb 04 2015 19:03
the problem with that integration is that it is the wrong direction
I think I need to run asyncio stuff on a tornado event loop
Thomas Kluyver
@takluyver
Feb 04 2015 19:03
I think that's what that integration does
but I'm a bit confused about it
I'm hunting for the code to see if that helps me understand
Andreas Klostermann
@akloster
Feb 04 2015 19:04
it's mindboggling
Thomas Kluyver
@takluyver
Feb 04 2015 19:09
Yeah, you're right; that's a tornado API wrapper around the asyncio event loop, you need the other way round
on the plus side, it's only ~150 lines of code
maybe it's similarly easy to make an asyncio wrapper for the tornado event loop
Andreas Klostermann
@akloster
Feb 04 2015 19:10
it should be manageable
I just need to integrate this select stuff
Jason Grout
@jasongrout
Feb 04 2015 19:14
Andreas Klostermann
@akloster
Feb 04 2015 19:15
thank you
Thomas Kluyver
@takluyver
Feb 04 2015 19:15
"I started to but it turned out to be more difficult than I expected."
:(
Jason Grout
@jasongrout
Feb 04 2015 19:16
perhaps we could use Trollius on python 2.x, to support a natural way to move forward? http://trollius.readthedocs.org/en/latest/asyncio.html#write-code-working-on-trollius-and-tulip
Andreas Klostermann
@akloster
Feb 04 2015 19:18
in the thread they say there is no reason to prefer asyncio-in-tornado over tornado-in-asyncio and that the direction shouldn't matter
Thomas Kluyver
@takluyver
Feb 04 2015 19:18
we could probably even run Tornado on top of the asyncio event loop if asyncio is available, and on Tornado's own event loop if not, but I'm going to guess that that's a post 3.0 kinda change
@akloster I don't think they've considered the case where you want to start using asyncio inside code that's already running a tornado event loop.
Andreas Klostermann
@akloster
Feb 04 2015 19:19
Again, I am just poking around a little... no particular usecase, just that it would be nice to not block the kernel when waiting for a server response or a device getting ready.
The ultimate solution would be to implement the kernel protocol on trollius/tulip since they have zmq already
but that's way more trouble than is warranted
Thomas Kluyver
@takluyver
Feb 04 2015 19:20
actually, a Python 3 aiozmq based kernel might be fairly easy to write, and would be a great demo
sigh
why are half the docs about aiozmq about its RPC things? I don't want RPC, I want messaging.
Andreas Klostermann
@akloster
Feb 04 2015 19:30
looks interesting though
Andreas Klostermann
@akloster
Feb 04 2015 19:48
and a aiozmq based kernel would be usable in any asyncio enabled application as a sort of debugging console...
What would be the first step to develop a kernel? Is there any kind of testing machinery so that I don't need to hook it up to a notebook instance at first?
Jason Grout
@jasongrout
Feb 04 2015 19:54
@jdfreder?
Jonathan Frederic
@jdfreder
Feb 04 2015 19:54
here
Jason Grout
@jasongrout
Feb 04 2015 19:54
I'm getting an error with the latest master in the tree view in the javascript console
Unhandled promise rejection Promise {[[PromiseStatus]]: "rejected", [[PromiseValue]]: TypeError: Cannot read property 'forEach' of undefined}
notebooklist.js:283 Unhandled promise rejection Promise {[[PromiseStatus]]: "rejected", [[PromiseValue]]: TypeError: Cannot read property 'forEach' of undefined}
and then Reenabling autorefresh too close to last tree refresh, not refreshing immediately again. from main.js:110
it looks like when I first display the tree, this.selected is undefined in notebooklist.js:232
yeah, so where is the .selected attribute in NotebookList defined when the tree view is first shown?
Jonathan Frederic
@jdfreder
Feb 04 2015 20:07
hmmm
.selected is define when the first selection event occurs
274 may be the problem
also I should probably be constructing it along with the list
I'll open a PR
Jonathan Frederic
@jdfreder
Feb 04 2015 20:14
ipython/ipython#7687
Andreas Klostermann
@akloster
Feb 04 2015 20:18
On further investigation I think writing a fully compatible asyncio kernel is a bit too much for me currently.... Most of the GUI interaction loop requires the original zmq stuff, which is similar, but not the same...
Thomas Kluyver
@takluyver
Feb 04 2015 20:19
fair enough
I might experiment with it at some point
:)
Jason Grout
@jasongrout
Feb 04 2015 20:54
@jdfreder: another comment: I think it's usually "Select none", rather than "deselect all"
@jdfreder: add it to the wiki! https://github.com/ipython/ipython/wiki/Widgets
Jonathan Frederic
@jdfreder
Feb 04 2015 20:58
Already did :)
Jason Grout
@jasongrout
Feb 04 2015 20:58
never mind, I see you already did
yeah
Jonathan Frederic
@jdfreder
Feb 04 2015 20:58
One of the students here is controlling a quadcopter with the IPython notebook
The flight attitude meter is easier to read than a textbox
Also I wanted to experiment with the nbextensions API
which I haven't done yet
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 20:59
I have a ipython notebook-control ev3-based two-wheeled robot
Jonathan Frederic
@jdfreder
Feb 04 2015 21:00
cool!
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 21:00
I was thinking of playing with the browser gamepad api
btw, the ev3 can run IPython very well.
(using ev3dev)
a Debian distrib for ev3
Jonathan Frederic
@jdfreder
Feb 04 2015 21:01
ev3 = lego mindstorms?
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 21:01
yes
Jonathan Frederic
@jdfreder
Feb 04 2015 21:01
cool
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 21:01
gyro / accelerometer sensor for balance
forked your repo
Thomas Kluyver
@takluyver
Feb 04 2015 21:47
@SylvainCorlay that's awesome
mindstorms has come on so much. I had the 1.5 version as a teenager
that definitely could not have run the notebook
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 21:48
I could not have it as a teenager, bought it in my 30s :)
Thomas Kluyver
@takluyver
Feb 04 2015 21:49
I would feel sorry for you, but now you have Linux on Lego
so...I don't ;-)
though you don't get the fun of plugging a custom IR transmitter into a COM port to transfer programs
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 21:51
yeah. you can still program your old mindstorm with C
nqc: not quite C
Thomas Kluyver
@takluyver
Feb 04 2015 21:57
yep
I found out about that, but I never got quite that advanced
I did step up from the super basic programming that came with it to use something called Gordon's Brick Programmer: http://www.cs.rit.edu/~ats/plcr-2003-1/reports/gordon/
(not the original homepage - that seems to have gone)
it had variables and everything!
My best creation was a code-lock box - I used the two touch sensors as buttons, and it would open when you pressed them in the right sequence.
</reminiscence>
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:01
A friend of mine made an arduino-based "secret code" door opener.
(with a microphone connected to the door to detect knocks)
Thomas Kluyver
@takluyver
Feb 04 2015 22:03
ooh, nice
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:05
" for his kids " (note the quotes)
Thomas Kluyver
@takluyver
Feb 04 2015 22:05
sure
I have a sneaking suspicion that half the reason people have kids is so they can do all kinds of fun things 'for the kids'
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:06
while I have to take the mindstoms upon myself
Thomas Kluyver
@takluyver
Feb 04 2015 22:07
very brave of you ;-)
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:16
@jdfreder I will try your widget with the gyro sensor this week end. Will post a video if get it to work
Jonathan Frederic
@jdfreder
Feb 04 2015 22:22
:)
Awesome!
@SylvainCorlay I'm excited to see how to turns out
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:23
oh, will need to use IPython 3 :)
Jonathan Frederic
@jdfreder
Feb 04 2015 22:40
If I've done something Python 3 only, it was unintentional.
Screen Shot 2015-02-04 at 2.40.04 PM.png
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 22:58
IPython, not python :)
this widget is awesome
Thomas Kluyver
@takluyver
Feb 04 2015 23:01
flight simulator in IPython widgets?
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 23:03
Not a simulator. In that case, the notebook server is literally pitching and rolling.
This message was deleted
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 23:08
@jdfreder we should add a yaw rule on that widget
Jonathan Frederic
@jdfreder
Feb 04 2015 23:09
Yeah @SylvainCorlay
I was thinking that or a separate widget
but I like your idea more
I think it's all the same (type of) information anyways
Ah I didn't see the I in front of Python in your message. I must have read it too quick.
Sylvain Corlay
@SylvainCorlay
Feb 04 2015 23:12
There could be a separate horizontal rule for the compass
(My inertial motion unit has a compas)
ok, it is official, I will look into your repo this week end.
Jonathan Frederic
@jdfreder
Feb 04 2015 23:21
Ok
I'll let you know if/when I write the compass widget, unless you get to it first, then please open a PR :)