Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print and logging not working in VSCode Jupyter for watched functions #7697

Open
bertcoerver opened this issue Feb 11, 2025 · 1 comment
Open

Comments

@bertcoerver
Copy link

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc should be added within the dropdown below.)

Software Version Info
python == 3.12.8
panel == 1.6.0
param == 2.2.0

Jupyter extension VSCode == 2025.1.0
VSCode == 1.97.0 

Python env created with conda from conda-forge.

Description of expected behavior and the observed behavior

A few days ago the below example was working fine for me, I could see the print and/or logging.info messages in the VSCode Jupyter Window. Now messages printed during __init__ still work, but when I print messages during an event callback, the messages don't appear in the Jupyter Window anymore (see the video below).

In the Jupyter Console I'm seeing the following messages:

Unhandled kernel message from a widget: stream : {"name":"stderr","text":"INFO:root:Clicked 1 times.\n"}

Complete, minimal, self-contained example code that reproduces the issue

import param
import logging
import panel as pn
pn.extension()
logging.basicConfig(
    encoding="utf-8",
    level=logging.INFO, 
    force=True
)

class Test(param.Parameterized):

    button = param.Action(default = lambda x: x.param.update(clicks = x.clicks + 1))
    clicks = param.Integer(default = 0)

    def __init__(self, **params):
        logging.info("Initiating")
        print("Initiating")
        super().__init__(**params)

    @param.depends("clicks", watch=True)
    def test(self):
        string = f"Clicked {self.clicks} times."
        logging.info(string)
        print(string)

test = Test()

pn.Row(test.param["button"], test.param["clicks"])

Stack traceback and/or browser JavaScript console output

09:36:48.361 [info] Generated code for 14 = <ipython-input-14-9638e8fa74be> with 29 lines
Unhandled kernel message from a widget: stream : {"name":"stderr","text":"INFO:root:Clicked 1 times.\n"}
Unhandled kernel message from a widget: stream : {"name":"stdout","text":"Clicked 1 times.\n"}

Screenshots or screencasts of the bug in action

Screen.Recording.2025-02-11.at.09.36.47.mov
@bertcoerver
Copy link
Author

bertcoerver commented Feb 11, 2025

Just downgraded to VSCode == 1.96.4 and things are back to normal. As in: the messages now show up in the Jupyter Window. I do still see those Unhandled kernel message from a widget: stream : messages as well though...

Now I don't know if this is a "bug" on holoviz side or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant