These are chat archives for ipython/ipython

5th
Mar 2015
Brian E. Granger
@ellisonbg
Mar 05 2015 00:07
Anyone know where we configure require.js? (What file)
Jonathan Frederic
@jdfreder
Mar 05 2015 00:11
templates/page.html
Cyrille Rossant
@rossant
Mar 05 2015 14:59
I'm facing a bug with a custom widget and comms. Some custom comm msgs are sent immediately after the creation/display of the widget with self.comm.send({...}). It seems like these msgs are lost (not received by the frontend) unless I add a small delay. Has anyone come across this before?
Jason Grout
@jasongrout
Mar 05 2015 15:08
I did, and we merged ipython/ipython#7801 to fix it.
well, maybe that would fix your issue. My issue was slightly different.
Cyrille Rossant
@rossant
Mar 05 2015 15:10
I'm using IPython master btw (pulled today)
Jason Grout
@jasongrout
Mar 05 2015 15:10
Also, ipython/ipython#7780 might fix it.
oh, then you have #7780 already
did the messages go across the wire? Can you check the websocket frames to see if they went across?
We've had some race conditions with the message processing. So question 1: did the message get across the wire. Question 2: was it processed out of order?
Cyrille Rossant
@rossant
Mar 05 2015 15:12
I think the messages never went across, but I can check
how do I check that?
Jason Grout
@jasongrout
Mar 05 2015 15:24
in Chrome dev tools, for example, look at the Network tab. Click "Websockets" at the top to get to the websocket connection, and look at the messages
Cyrille Rossant
@rossant
Mar 05 2015 15:26
thanks
found it
so no the messages never arrive
Jason Grout
@jasongrout
Mar 05 2015 15:27
You'll probably want to refresh the page. I don't things are logged there until its open
Cyrille Rossant
@rossant
Mar 05 2015 15:28
yeah I did
I see some messages
but not the very first
Jason Grout
@jasongrout
Mar 05 2015 15:28
can you paste the messages you see?
Cyrille Rossant
@rossant
Mar 05 2015 15:33
ok this time I see none of my custom messages
{'buffers': [],
  'channel': 'shell',
  'content': {'banner': 'Python 3.4.2 |Anaconda 2.1.0 (64-bit)| (default, '
                        'Oct 21 2014, 17:16:37) \n'
                        'Type "copyright", "credits" or "license" for more '
                        'information.\n'
                        '\n'
                        'IPython 3.1.0-dev -- An enhanced Interactive '
                        'Python.\n'
                        "? -> Introduction and overview of IPython's "
                        'features.\n'
                        '%quickref -> Quick reference.\n'
                        "help -> Python's own help system.\n"
                        "object? -> Details about 'object', use 'object??' "
                        'for extra details.\n'
                        '%guiref -> A brief reference about the graphical '
                        'user interface.\n',
              'help_links': [{'text': 'Python',
                              'url': 'http://docs.python.org/3.4'},
                             {'text': 'IPython',
                              'url': 'http://ipython.org/documentation.html'},
                             {'text': 'NumPy',
                              'url': 'http://docs.scipy.org/doc/numpy/reference/'},
                             {'text': 'SciPy',
                              'url': 'http://docs.scipy.org/doc/scipy/reference/'},
                             {'text': 'Matplotlib',
                              'url': 'http://matplotlib.org/contents.html'},
                             {'text': 'SymPy',
                              'url': 'http://docs.sympy.org/latest/index.html'},
                             {'text': 'pandas',
                              'url': 'http://pandas.pydata.org/pandas-docs/stable/'}],
              'implementation': 'ipython',
              'implementation_version': '3.1.0-dev',
              'language_info': {'codemirror_mode': {'name': 'ipython',
                                                    'version': 3},
                                'file_extension': '.py',
                                'mimetype': 'text/x-python',
                                'name': 'python',
                                'nbconvert_exporter': 'python',
                                'pygments_lexer': 'ipython3',
                                'version': '3.4.2'},
              'protocol_version': '5.0'},
  'header': {'date': '2015-03-05T16:30:25.570624',
             'msg_id': 'aaba495e-e268-4f4b-bb7d-55a036d49964',
             'msg_type': 'kernel_info_reply',
             'session': '59f6e7a2-b8dc-4f61-9b80-211b429c18f2',
             'username': 'cyrille',
             'version': '5.0'},
  'metadata': {},
  'msg_id': 'aaba495e-e268-4f4b-bb7d-55a036d49964',
  'msg_type': 'kernel_info_reply',
  'parent_header': {'msg_id': 'C78D26C2F9164AF6939038D4CEEB7FCC',
                    'msg_type': 'kernel_info_request',
                    'session': '074ABD323B2148C88310B17D169A1220',
                    'username': 'username',
                    'version': '5.0'}},
 {'buffers': [],
  'channel': 'iopub',
  'content': {'execution_state': 'idle'},
  'header': {'date': '2015-03-05T16:30:25.571114',
             'msg_id': '62cceefb-0fc4-483b-85fb-ae4b4f09851e',
             'msg_type': 'status',
             'session': '59f6e7a2-b8dc-4f61-9b80-211b429c18f2',
             'username': 'cyrille',
             'version': '5.0'},
  'metadata': {},
  'msg_id': '62cceefb-0fc4-483b-85fb-ae4b4f09851e',
  'msg_type': 'status',
  'parent_header': {'msg_id': 'C78D26C2F9164AF6939038D4CEEB7FCC',
                    'msg_type': 'kernel_info_request',
                    'session': '074ABD323B2148C88310B17D169A1220',
                    'username': 'username',
                    'version': '5.0'}},
 {'buffers': [],
  'channel': 'iopub',
  'content': {'execution_state': 'busy'},
  'header': {'date': '2015-03-05T16:30:25.570316',
             'msg_id': '4552f542-fa4e-4951-b0b6-575a45c03312',
             'msg_type': 'status',
             'session': '59f6e7a2-b8dc-4f61
my application stops if the first message is not received
so I can't see the next ones
a 50ms delay seems to work on my setup..
Cyrille Rossant
@rossant
Mar 05 2015 15:39
I should note that I instanciate and show the widget in the same cell
Cyrille Rossant
@rossant
Mar 05 2015 16:03
sorry I was wrong, it does look like the messages arrive and are processed in order... the problem might be in my code. I need to check...
Jason Grout
@jasongrout
Mar 05 2015 16:10
okay
Cyrille Rossant
@rossant
Mar 05 2015 16:11
might have found the pb
currently I have this in my widget's render function:
this.model.comm.on_msg($.proxy(this.on_msg, this));
then I define on_msg()
that may not be the right way to do it?
I want a custom callback function in my frontend widget to react to custom comm messages I'm sending from the backend
Jason Grout
@jasongrout
Mar 05 2015 16:12
the render is only called after the widget is displayed
Cyrille Rossant
@rossant
Mar 05 2015 16:13
yeah, hence the race condition probably
Jason Grout
@jasongrout
Mar 05 2015 16:14
you'll notice here that we trigger an event when a custom message comes:
you'll need to register a handler for that in your initialize method
initialize is called on creation. Make sure to call the super's initialize too, though
Cyrille Rossant
@rossant
Mar 05 2015 16:16
excellent, trying it now
Cyrille Rossant
@rossant
Mar 05 2015 16:21
ok I still have a problem :(
the comms are received in the frontend
but my JS handler is not called
here is the code
    var VispyView = widget.DOMWidgetView.extend({

        initialize: function (parameters) {
            VispyView.__super__.initialize.apply(this, [parameters]);

            this.model.on('msg:custom', this.on_msg, this);

            // Track canvas size changes.
            this.model.on('change:width', this.size_changed, this);
            this.model.on('change:height', this.size_changed, this);
        },
        on_msg: function(comm_msg) {
            console.log("RECEIVED");
            console.log(comm_msg);
            return;
       }
nothing shows up in the console whereas I can see in the websocket inspector that the comms arrive
Jason Grout
@jasongrout
Mar 05 2015 16:27
I would suggest as a next step to put in some breakpoints and start stepping through. For example, you could breakpoint https://github.com/ipython/ipython/blob/master/IPython/html/static/widgets/js/widget.js#L154 and your function and see what happens.
Cyrille Rossant
@rossant
Mar 05 2015 16:27
ok thanks
Cyrille Rossant
@rossant
Mar 05 2015 16:39
is it possible that comms are sent before the JS model's initialize() is called?
so the on_msg handler hasn't been registered yet by the time the first comm arrives?
everything seems to work when I put breakpoints (heisenbug)
I guess it's still a race condition of some sort
Jason Grout
@jasongrout
Mar 05 2015 16:40
Very odd.
Cyrille Rossant
@rossant
Mar 05 2015 16:41
what is the correct way to send a first comm once the widget is first displayed?
Jason Grout
@jasongrout
Mar 05 2015 16:41
you mean send a custom messager?
message?
Cyrille Rossant
@rossant
Mar 05 2015 16:41
yes
Jason Grout
@jasongrout
Mar 05 2015 16:43
create the object (which should initialize the model and call the initialize js method), and then use https://github.com/ipython/ipython/blob/master/IPython/html/widgets/widget.py#L255 to send the message
are you sending the message directly on the comm, or are you using the widget's send method?
Cyrille Rossant
@rossant
Mar 05 2015 16:44
I use self.comm.send({"method": "custom", "content": msg})
I didn't have those problems before IPython 3.0: is this because the widget stuff has become asynchronous somehow?
Jason Grout
@jasongrout
Mar 05 2015 16:45
most likely
it has something to do with async stuff
Cyrille Rossant
@rossant
Mar 05 2015 16:46
the bug fixes you referred to earlier were about non-custom comms?
Jason Grout
@jasongrout
Mar 05 2015 16:46
the bug fixes before were about messages getting processed out of order because of async issues
in particular, loading a widget model is async now, so it could be pushed past the processing of other messages
Cyrille Rossant
@rossant
Mar 05 2015 16:47
I see. so my custom msg is sent before the JS gets a chance to register a handler for custom msgs
Jason Grout
@jasongrout
Mar 05 2015 16:48
that may be what is happening.
but the processing of the custom message should be delayed until after the initialize method is called
Cyrille Rossant
@rossant
Mar 05 2015 16:48
should I open an issue on GH then? do you think it should be fixed in IPython or in my app (i.e. waiting a bit before sending custom messages)
Jason Grout
@jasongrout
Mar 05 2015 16:48
it should work without waiting.
if you can debug it further, with those ideas in mind
you can see if the custom messages could jump ahead in the queue
Cyrille Rossant
@rossant
Mar 05 2015 16:51
you mean out of order?
Jason Grout
@jasongrout
Mar 05 2015 16:51
one thing that troubles me is that the custom message handler at https://github.com/ipython/ipython/blob/master/IPython/html/static/widgets/js/widget.js#L154 doesn't have the same logic as, for example, the display message has about the state_change thing
that might be where comm messages are processed first.
if you open a github issue, please be sure to attach a working test case.
(or non-working test case, I mean)
Cyrille Rossant
@rossant
Mar 05 2015 16:52
yeah okay :)
I'll do that then
thanks for your help!!
Jason Grout
@jasongrout
Mar 05 2015 16:52
I don't know if others are using custom messages very much with widgets, so it may be that this hasn't be exercised very much
even better, attach a patch to the github issue :)
Cyrille Rossant
@rossant
Mar 05 2015 16:53
it's not a bad practice right?
Jason Grout
@jasongrout
Mar 05 2015 16:53
no, custom messages should work and be processed in order, automatically
though you might use the widget's send method instead of reaching down to the comm
that would be better practice
Cyrille Rossant
@rossant
Mar 05 2015 16:53
yeah but I'll need binary websocket
and the widget's send() hasn't it I think
Jason Grout
@jasongrout
Mar 05 2015 16:54
ah. I'm working on a PR that will enable that.
Cyrille Rossant
@rossant
Mar 05 2015 16:54
oh great
Jason Grout
@jasongrout
Mar 05 2015 16:54
ipython/ipython#7757
Cyrille Rossant
@rossant
Mar 05 2015 16:55
yep that's exactly what I needed
Jason Grout
@jasongrout
Mar 05 2015 16:56
it's on the back burner right now, but I might work on it next week in the IPython dev meeting days.
Cyrille Rossant
@rossant
Mar 05 2015 16:57
no problem
Jason Grout
@jasongrout
Mar 05 2015 17:01
@minrk: regarding the origin access control conversation above, you said, "you can change it via config, but we shouldn't allow it by default.". Did you mean we can change it right now, or that we can submit a PR to allow changing it in the config?
Min RK
@minrk
Mar 05 2015 17:21
@jasongrout right now, allow_origin is configurable.
Jason Grout
@jasongrout
Mar 05 2015 17:25
ah, --NotebookApp.allow_origin, --NotebookApp.allow_origin_pat. Thanks
Daniel Kinzler
@brightbyte
Mar 05 2015 17:46
hi all! Is there a way to run ipython notebook as a uwsgi app?
Min RK
@minrk
Mar 05 2015 17:51
I don't think so
jgoad
@jgoad
Mar 05 2015 18:14
I just installed Python 3 on my machine, but my existing IPython doesn't recognize it. I even pip installed -e .[all]. How can I get my IPython installtion to register a Python 3 kernel for it?
Nvm
I found out that I could copy the Python 2 kernel and muck with the JSON to get it to work!
Min RK
@minrk
Mar 05 2015 18:22
python3 -m IPython kernelspec install-self [--user]
Mathieu
@mathieu1
Mar 05 2015 20:13
Out of sheer curiosity, is the dashboard currently customizable? Like adding a custom tab or something?
Min RK
@minrk
Mar 05 2015 20:27
Not really
Not intentionally, at least
Daniel Kinzler
@brightbyte
Mar 05 2015 20:28
yea, figured that out. i'm not running the standalone server.
i'm a bit confused though. it doesn't seem to use the config in ~/.ipython
i'm using virtualenv... should the profile go into the venv? how do these interact?
Min RK
@minrk
Mar 05 2015 20:29
venv does not interact with config at all
what are you configuring?
Daniel Kinzler
@brightbyte
Mar 05 2015 20:31
i'm trying to run a public notebook from a box where i don't have root. i can run the standalone web server on a grid engine though, and access it via a proxy.
i'm trying to keep notebook from opening a browser on startup.
Min RK
@minrk
Mar 05 2015 20:32
setting via config file, or --no-browser on CLI?
Daniel Kinzler
@brightbyte
Mar 05 2015 20:32
config file. c.NotebookApp.open_browser = False
Min RK
@minrk
Mar 05 2015 20:32
And where is that file?
Daniel Kinzler
@brightbyte
Mar 05 2015 20:32
in ~/.ipython/profile_nbserver/ipython_notebook_config.py
Min RK
@minrk
Mar 05 2015 20:33
ok
and how are you starting the server?
Daniel Kinzler
@brightbyte
Mar 05 2015 20:33
source ~/www/python/venv/bin/activate
ipython notebook --port "$port"
i'll try the cli option.
would be good to know why the config doesn't work, though
Min RK
@minrk
Mar 05 2015 20:33
ok, that would be part of it - you put the config file in a non-default profile, but then starting the server without specifying a profile
Mathieu
@mathieu1
Mar 05 2015 20:34
@minrk Does that look like something that could be considered? "Dashboard extensions" might sound trivial, but on another hand that could be a cheap way of allowing experimentation and maybe coming up with interesting ideas, while staying away from IPython master.
Min RK
@minrk
Mar 05 2015 20:34
either put the config in profile_default, or start the server with --profile nbserver
Daniel Kinzler
@brightbyte
Mar 05 2015 20:34
oh, i see! "nbserver" is the non-standard profile name? would be renaming the folder be sufficient? what should it be renamed to?
i have no experience with ipython or virtualenv. i'm mostly a php coder these days...
Min RK
@minrk
Mar 05 2015 20:35
@brightbyte profile_default
Daniel Kinzler
@brightbyte
Mar 05 2015 20:35
kk
Min RK
@minrk
Mar 05 2015 20:35
@mathieu1 it's fine, in that you can execute extra code via custom.js to modify the dashboard. I'm not sure we should be enabling more than that, though.
Mathieu
@mathieu1
Mar 05 2015 20:36
Ah, right, that is already possible then... Will look into that, thanks
Daniel Kinzler
@brightbyte
Mar 05 2015 20:36
ok, it's up, and no browser. thanks!
i'll fiddle with the proxy setup now
success! partly. i'm taling to tornade, it seems. but it says:
404 : Not Found
You are requesting a page that does not exist!
i'm starting out at /ipython, which is the base path the proxy assigned to me.
oh, i see (partially)
Daniel Kinzler
@brightbyte
Mar 05 2015 20:42
notbook thinks it's running in "/", but it's behindm a proxy, the external path is "/ipython"
how do i tell it the base path?
Min RK
@minrk
Mar 05 2015 20:42
when behind a proxy, you generally need to specify the base_url
set NotebookApp.base_url='/ipython/'
Daniel Kinzler
@brightbyte
Mar 05 2015 20:44
yea, found it. let's see...
Daniel Kinzler
@brightbyte
Mar 05 2015 20:51
hm, blank page now
it does contain html. but no text. tries to load the auth script.
it's laoding https://tools.wmflabs.org/ipython/static/style/style.min.css.map six times, takes forever :)
loading jquery-ui times out. hm.
Daniel Kinzler
@brightbyte
Mar 05 2015 21:47
hm, i have the notebook working now, but can't get matplotlib to actually output graphics.
i get <matplotlib.text.Text at 0x2b9ebdbe9190>
am i missing something obvious?
Jonathan Frederic
@jdfreder
Mar 05 2015 21:51
Is your Javascript console displaying any errors?
Jonathan Frederic
@jdfreder
Mar 05 2015 21:59
@takluyver is the nbextension command line API documented anywhere? I was unable to find it in the what's new section of the docs for 3.x
Kyle Polich
@kylepolich
Mar 05 2015 22:13
Hello Jupyter team. I'm a huge fan and user of ipython notebook. I enjoyed meeting some of you guys after the talk at Strata. I'm going to lurk for a while but have hopes of easing myself into being a contributor.
Matthias Bussonnier
@Carreau
Mar 05 2015 22:19
Hi @kylepolich ask if you have any questions !
we don't bite, so don't hesitate !
jl45621
@jl45621
Mar 05 2015 22:33
hi guys, first off thanks for everything! the ipython notebook is probably the coolest tool i use on a daily basis. secondly -- has anyone any idea on how to prevent charts from stretching off to the right? i'm hoping its an easy CSS fix but im not a web guy so i'm not sure how to even begin debugging it
Thomas Kluyver
@takluyver
Mar 05 2015 22:37
it is easy-ish, but unfortunately when we fixed it, it turned out that some people liked that behaviour, to let them look closely at bigger graphs
so we changed it back
jl45621
@jl45621
Mar 05 2015 22:37
oh i just thought to check the ipython pull requests and found this one: https://github.com/ipython/ipython/pull/7718/files
oh ok gotcha
Thomas Kluyver
@takluyver
Mar 05 2015 22:38
Yep, there was that and #7721
7721 was the one that actually got merged
jl45621
@jl45621
Mar 05 2015 22:51
maybe the ideal solution is to have it by default look pretty (and stay within the edges) but if user wants more detail, they can click on it and a popup will show them more detail
maybe this might help http://jqueryui.com/dialog/
looks like this one is better though: http://dimsemenov.com/plugins/magnific-popup/
Thomas Kluyver
@takluyver
Mar 05 2015 22:55
yes, I think we'd like to do something like that. This came up just before 3.0 was released, so we didn't want to start adding functionality.
Jason Grout
@jasongrout
Mar 05 2015 23:26
@minrk?
Min RK
@minrk
Mar 05 2015 23:27
@jasongrout