These are chat archives for ipython/ipython

18th
Nov 2014
Damian Avila
@damianavila
Nov 18 2014 00:01
I saw what @ellisonbg described too...
Btw... I am back from a mini-season of several conferences (including PyCon Brasil where I have really nice talks with Fernando), so now time to catch up on the newest things :wink:
@/all, are you guys/gals doing a supplementary meeting tomorrow? or it only raises only when it is needed?
Jonathan Frederic
@jdfreder
Nov 18 2014 00:13
Only when needed
Damian Avila
@damianavila
Nov 18 2014 00:34
thx
Thomas Kluyver
@takluyver
Nov 18 2014 01:22
@ellisonbg I recall an issue like that which I fixed in teminado. pip install --upgrade terminado and try again. If it persists, make sure that you have Tornado 4.
Doug Blank
@dsblank
Nov 18 2014 01:34
@takluyver confirming that upgrading from terminado 0.2 to 0.3.1 fixed the infinite loop shutting down a terminal
Thomas Kluyver
@takluyver
Nov 18 2014 01:45
great, thanks
Brian E. Granger
@ellisonbg
Nov 18 2014 05:17
OK great I will update terminado...
Stuart Mumford
@Cadair
Nov 18 2014 09:47
@Carreau What I meant was the ability to list all the venvs automatically. Manually writing a kernelspec for the venv is easy enough.
Matthias Bussonnier
@Carreau
Nov 18 2014 09:49
ah, ok I missunderstood !
Stuart Mumford
@Cadair
Nov 18 2014 09:59
Is there a way to replace the KernelSpecManager? On a config level?
Then you could make a subclass that lists venvs
Matthias Bussonnier
@Carreau
Nov 18 2014 10:10
@Cadair it might be a configurable, let me check
seem to be, but not set to config=True
weird.
Matthias Bussonnier
@Carreau
Nov 18 2014 10:15
notebookapp.py line 614, try to set config=True, then you can ad to config: Notebookapp.kernel_spec_manager='Yourclass'
Stuart Mumford
@Cadair
Nov 18 2014 10:16
@Carreau cool I will give that a try this afternoon
Matthias Bussonnier
@Carreau
Nov 18 2014 10:17
you can also submit a PR that make it configurable and add docs and.or open an issue to remind us (or SO else) to do so.
Stuart Mumford
@Cadair
Nov 18 2014 10:17
ok
If I get it working I will open a PR with the change.
Matthias Bussonnier
@Carreau
Nov 18 2014 10:18
Ok, great !
Stuart Mumford
@Cadair
Nov 18 2014 10:18
There is no such thing as a global config is there?
Matthias Bussonnier
@Carreau
Nov 18 2014 10:21
You might need to replace Instance by DottedObjectName though
And add some logic to import
Stuart Mumford
@Cadair
Nov 18 2014 10:22
huh?
Matthias Bussonnier
@Carreau
Nov 18 2014 10:22
Are you familiar with IPython config system ?
Stuart Mumford
@Cadair
Nov 18 2014 10:22
not really
:D
Matthias Bussonnier
@Carreau
Nov 18 2014 10:23
Ok, lets say you have a class with an class attribute foo = Bool(True, config=True)
Stuart Mumford
@Cadair
Nov 18 2014 10:23
ok
Matthias Bussonnier
@Carreau
Nov 18 2014 10:23
then it will automatically create a config key 'ClassName.foo' in config files.
Stuart Mumford
@Cadair
Nov 18 2014 10:23
cool
Matthias Bussonnier
@Carreau
Nov 18 2014 10:23
and in place of Bool, you can have lots of things like Enum, Int, Unicode...
Stuart Mumford
@Cadair
Nov 18 2014 10:24
traits?
Matthias Bussonnier
@Carreau
Nov 18 2014 10:24
"Instance" allow you to pass actually a Class object to the config file.
and it will take care of instanciating it.
Stuart Mumford
@Cadair
Nov 18 2014 10:24
nice
Matthias Bussonnier
@Carreau
Nov 18 2014 10:25
If you use DottedObjectName, the value can be a Instance or a string, (like 'MyPackage.foo.bar',) and it will automatically import that
Though as it does not know wether you want the class object or an instance, it does not instanciate.
in notebookapp.py have a look at contents_manager_class,kernel_manager_class and other to see how they work.
Stuart Mumford
@Cadair
Nov 18 2014 10:28
so that has to import an instance?
for the kernelspecmanager
Matthias Bussonnier
@Carreau
Nov 18 2014 10:31

yep, you do as

kls = import_item(self.contents_manager_class)
self.contents_manager = kls(parent=self, log=self.log)

but for the kernelspec manager.

so probably a
class ....
   kernel_spec_manager_class = DottedObjectName('IPython.xxx.xxxx', config=True, help='...')


   kls = import_item(self.kernel_spec_manager_class)
   self.kernel_spec_manager = kls(parent=self, log=self.log)
Stuart Mumford
@Cadair
Nov 18 2014 10:33
this in the notebookapp?
as opposed to the config class
Matthias Bussonnier
@Carreau
Nov 18 2014 10:34
yes, in notebookapp.py
Stuart Mumford
@Cadair
Nov 18 2014 10:35
makes sense
Matthias Bussonnier
@Carreau
Nov 18 2014 10:35
once this is done, in notebook_config.py you just do
Notebookapp.kernel_spec_manager_class = 'MyPackage.MyManager'
Stuart Mumford
@Cadair
Nov 18 2014 10:36
thanks for your help
Scott Sanderson
@ssanderson
Nov 18 2014 15:04
@Carreau @Cadair you can also pass a string directly to the Instance trait and it will do the importing and instantiating logic you described above
Matthias Bussonnier
@Carreau
Nov 18 2014 15:08
Hum, indeed. I'm not sure why we have dotted object name then.
there is probable a bunch of code we could simplify then
Hum, maybe they need custom param as initialisation, have to look at that,
Stuart Mumford
@Cadair
Nov 18 2014 15:58
@Carreau is there somewhere I can put my custom class without making a whole new package?
Matthias Bussonnier
@Carreau
Nov 18 2014 16:00
in current working directory, it should see it as a package at launch time
Stuart Mumford
@Cadair
Nov 18 2014 16:00
good enough
thanks
Matthias Bussonnier
@Carreau
Nov 18 2014 16:01
after you create a pseudo module somewher in your pythonpath
I use to have a "package" call 'me' with thinngs i used often during phd.
I was importing 'me' all the time :-)
Stuart Mumford
@Cadair
Nov 18 2014 16:02
haha
Stuart Mumford
@Cadair
Nov 18 2014 17:23
@Carreau I can't get this DotteedObjectName thing to play ball
Matthias Bussonnier
@Carreau
Nov 18 2014 17:24
Do you want to open a PR (even not working) and we to that slowly, or Just one of us to take care of it ?
Stuart Mumford
@Cadair
Nov 18 2014 17:26
if I try and do an import_item() I get something about DottedObjectName not having .rfind
or rsplit
whatever it is
basically, this dosen't quack much like a string
Matthias Bussonnier
@Carreau
Nov 18 2014 17:26
ok, Do you have your code somewhere ?
Stuart Mumford
@Cadair
Nov 18 2014 17:27
I will open a PR but it's a bit of a mess at the moment as I have been learning by random code
Matthias Bussonnier
@Carreau
Nov 18 2014 17:27
(on github or alike)
no problem, just open even crapy somethingm and say that it's to get help
it's up o you wether you want to spend some time learning.
Scott Sanderson
@ssanderson
Nov 18 2014 17:30
@Cadair I think you want to change DottedObjectName there to Type
Matthias Bussonnier
@Carreau
Nov 18 2014 17:30
Ah, don't do the kls in the body of the class, it will not work
Scott Sanderson
@ssanderson
Nov 18 2014 17:31
and yeah, the traitlets stuff works by mucking with the class object after it's created, you can't do that stuff inline in the body of the class
Matthias Bussonnier
@Carreau
Nov 18 2014 17:31
you need to do in in a method
either in __init__,
Stuart Mumford
@Cadair
Nov 18 2014 17:31
@Carreau that thought crossed my mind, however I couldn't find a method where to do it?
hmmm
Matthias Bussonnier
@Carreau
Nov 18 2014 17:32
or just before kernel_spec_manager is used for the first time
let e see
init_webapp ~line 732
Stuart Mumford
@Cadair
Nov 18 2014 17:33
changing it to Type made an interestingly different error
Scott Sanderson
@ssanderson
Nov 18 2014 17:33
Type exists to do more or less what it sounds like you want to do; namely, resolve a string into a class at runtime
Stuart Mumford
@Cadair
Nov 18 2014 17:34
@ssanderson I need to resolve a string to an instance
but yeah
Scott Sanderson
@ssanderson
Nov 18 2014 17:34
ah
then Instance
may be what you want instead
Stuart Mumford
@Cadair
Nov 18 2014 17:35
@Carreau moving the instantiation into the method seemed to work, but my custom code doesn't seem to be executing.
Matthias Bussonnier
@Carreau
Nov 18 2014 17:36
yeah, but these Instance don't allow pasing custom args.
(I'm in hangout now, i'll be back after)
Stuart Mumford
@Cadair
Nov 18 2014 17:37
Thanks for your help
I am not going to be working on this again for a few days
if anyone has time to fix it then that would be great, otherwise I am happy to keep going when I get the time
Matthias Bussonnier
@Carreau
Nov 18 2014 17:38
Ok, you can open an issue, I'll take care of it probably
you can add a link to what you already did
Stuart Mumford
@Cadair
Nov 18 2014 17:39
thanks a lot @Carreau
Matthias Bussonnier
@Carreau
Nov 18 2014 17:40
Technically that will retroactively be my job :-)
Stuart Mumford
@Cadair
Nov 18 2014 17:40
eh?
Matthias Bussonnier
@Carreau
Nov 18 2014 17:41
(I'll be hired by Berkeley to work on IPython soon just need to finish signing, and will be started yesterday)
(hopefully)
Stuart Mumford
@Cadair
Nov 18 2014 17:41
nice one!
have fun with that!
Matthias Bussonnier
@Carreau
Nov 18 2014 17:41
Of course !
Sylvain Corlay
@SylvainCorlay
Nov 18 2014 23:41

Hello,
I have a question of scope: I have locally modified utils.traitlets.link and dlink to be safe, meaning that assignment is protected by try / catch statements.
link and dlink take two additional optional named arguments, success (a tuple (hasTrait instance, name)) and message (another tuple (hasTrait instance, name)).

In the case when a TraitError occurs (failed validation), success.v is set to False and message.v is set to the TraitError message. In case of success, the message is set to an empty string and the success to True. This is especially convenient when you want to validate a user input on the fly and use the traitlet validation mechanism to do that. (And notify the user via another widget for example).

Would it make sense to modify the corresponding upstream functions to be that way?