holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
423 stars 73 forks source link

Only warnings are displayed from param in ipython notebooks? #68

Open ceball opened 9 years ago

ceball commented 9 years ago

Logging seems to behave differently under ipython notebook vs. python

Python:

>>> import param
>>> param.Parameterized().warning('hi')
WARNING:root:Parameterized00002: hi
>>> param.Parameterized().message('hi')
INFO:root:Parameterized00003: hi
>>> param.parameterized.get_logger().isEnabledFor(param.parameterized.INFO)
True

In a notebook, however, I only get the warning message (not the info): ipython-logging

ceball commented 9 years ago

How this has been addressed in topographica (I guess):

# Create new logger to ensure param logging shows in notebooks
iplogger = logging.getLogger('ip-param')
iplogger.addHandler(logging.StreamHandler(stream=sys.stderr))
iplogger.propagate = False
param.parameterized.logger = iplogger

https://github.com/ioam/topographica/blob/master/platform/ipython/profile_topo/startup/notebook_setup.py#L11

jbednar commented 9 years ago

Does that seem like something that could go into param instead? If so, I'm happy to see things move out of Topographica and into lower-level libraries where they make sense...

jlstevens commented 9 years ago

You can move this to param if you like.

This was added because param logging behaved badly in IPython Notebooks without it. If you have a better idea of how info messages should behave in notebooks, go ahead and implement it.

ceball commented 7 years ago

Check if this is still a problem

FRidh commented 4 years ago

Not sure if this is the right ticket, but it seems not possible to hide param warnings in a notebook with

import warnings
warnings.filterwarnings('ignore')

Only the following hack at the end of the execution works:

%%javascript
$('div.output_stderr').hide();
maximlt commented 1 year ago

Not sure if this is the right ticket, but it seems not possible to hide param warnings in a notebook with

Indeed param warnings are using Python's logging to cannot be filtered via the warnings module. You have to manipulate param's logger to hide the warnings.

jbednar commented 1 year ago

I think the Aug 11, 2020 issue is the opposite of this one; both are worth addressing, but separately (e.g. by making Param warnings use warnings rather than logging, and making the fix in this issue).