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

Debugger widget #2548

Merged
merged 26 commits into from
Apr 10, 2022
Merged

Debugger widget #2548

merged 26 commits into from
Apr 10, 2022

Conversation

hyamanieu
Copy link
Collaborator

@hyamanieu hyamanieu commented Jul 20, 2021

Added debugger widget. Fixes #2062
NB: only interesting change in reactive.py is within _process_events
Sample code to try out:

import panel as pn
import param
pn.extension()
class A(param.Parameterized):

    with_throttled_enabled = param.Range(
        default=(100, 250),
        bounds=(0, 250),
    )

    def __init__(self, **params):
        super().__init__(**params)
        widgets = {
            "with_throttled_enabled": {
                "type": pn.widgets.IntRangeSlider,
                "throttled": False,
            },
        }
        self.controls = pn.Param(self, widgets=widgets)

        
    @param.depends("controls")
    #@status_decorator(behavior='erase')
    def calculation(self):
        if self.with_throttled_enabled[0] > 130:
            raise ValueError('too low')
        return pn.Pane((self.with_throttled_enabled), min_width=200)

    @param.depends("controls")
    #@status_decorator(behavior='erase')
    def buggy_calculation(self):
        return pn.Pane(self.with_throttled_enabled[1]/self.with_throttled_enabled[0], min_width=200)

a = A()


debug = pn.widgets.Debugger(name='Debugger')


a = pn.Column(a.controls, pn.pane.Markdown('### will bug above 130'), 
          a.calculation, 
          pn.pane.Markdown('### division by 0'), 
          a.buggy_calculation, 
          debug,
          )
a.servable()

To-do:

  • Correct visualization defaults
  • Correct button locations
  • Add example notebooks for the doc
  • Add test
  • make sure the console output works as usual in a notebook.

panel/reactive.py Outdated Show resolved Hide resolved
panel/reactive.py Outdated Show resolved Hide resolved
panel/reactive.py Outdated Show resolved Hide resolved
@philippjfr
Copy link
Member

This looks great! However it looks like you started with an old(er) checkout and simply undid a bunch of recent changes when you rebased.

@hyamanieu
Copy link
Collaborator Author

hyamanieu commented Jul 20, 2021 via email

@hyamanieu
Copy link
Collaborator Author

I can't get to have an exception accumulated in a notebook cell, even with master branch & 0.11.3. Not sure how ServableMixing._on_error gets triggered.

@philippjfr
Copy link
Member

Would be great to take this opportunity to add a bunch more log statements throughout the codebase as. The places you identified are definitely good but there's probably a bunch more that would help.

@hyamanieu
Copy link
Collaborator Author

Would be great to take this opportunity to add a bunch more log statements throughout the codebase as. The places you identified are definitely good but there's probably a bunch more that would help.

I identified the functions called whenever a callback is fired.

I would use panel.callbacks logger only when the end user is the target, not the Panel developers. Or what is your intent?

@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #2548 (0f4c5b2) into master (db8e0ac) will increase coverage by 0.00%.
The diff coverage is 85.79%.

@@           Coverage Diff            @@
##           master    #2548    +/-   ##
========================================
  Coverage   83.36%   83.37%            
========================================
  Files         196      198     +2     
  Lines       26486    26776   +290     
========================================
+ Hits        22081    22325   +244     
- Misses       4405     4451    +46     
Impacted Files Coverage Δ
panel/reactive.py 77.44% <22.22%> (+0.07%) ⬆️
panel/io/callbacks.py 78.86% <25.00%> (-1.82%) ⬇️
panel/widgets/debugger.py 88.37% <88.37%> (ø)
panel/tests/layout/test_base.py 100.00% <100.00%> (ø)
panel/tests/widgets/test_debugger.py 100.00% <100.00%> (ø)
panel/widgets/__init__.py 100.00% <100.00%> (ø)
panel/io/datamodel.py 43.75% <0.00%> (-5.21%) ⬇️
panel/pane/plotly.py 81.90% <0.00%> (-3.08%) ⬇️
panel/pane/base.py 88.00% <0.00%> (-0.89%) ⬇️
panel/pane/holoviews.py 79.24% <0.00%> (-0.63%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db8e0ac...0f4c5b2. Read the comment docs.

@philippjfr
Copy link
Member

I would use panel.callbacks logger only when the end user is the target, not the Panel developers. Or what is your intent?

No that makes sense. Just wondering if we can have a few log levels. I'm also thinking of adding an /admin endpoint to a server if requested, which provides details about the active sessions and optionally provides access to detailed logs as well.

@hyamanieu
Copy link
Collaborator Author

I would use panel.callbacks logger only when the end user is the target, not the Panel developers. Or what is your intent?

No that makes sense. Just wondering if we can have a few log levels. I'm also thinking of adding an /admin endpoint to a server if requested, which provides details about the active sessions and optionally provides access to detailed logs as well.

A bit like in jupyterhub, that could be helpful indeed. But that could be left at the discretion of the developing user, all the tools are already there to do such a thing.

panel/reactive.py Outdated Show resolved Hide resolved
@philippjfr
Copy link
Member

Sorry I left this so late to review, I've cleaned this up a bit and changed it to subscribe to the main panel logger. I'm still a little bit concerned about the brittleness of the width/height/sizing_mode handling which was pretty broken when I first looked at this. I've had to make some changes to terminal sizing but I don't think this handles every combination of min/max_width/height options and different sizing modes correctly. I do want to get a 0.13.0 RC release out today. Will try to clean this up more and get it in.

@hyamanieu
Copy link
Collaborator Author

hyamanieu commented Apr 4, 2022

Philipp, thanks for your review & corrections.
I have a bettered version of this widget in a separate project, I still didn't have the time to add it within this branche of Panel and won't have time for the next two weeks.

Some features that my experience with my user case made me add:

  • I have fixed some sizing problems between card & terminal, although I may have not thoroughly tested it like you as I simply fixed it.
  • I have added the possibility to optionally subscribe to additional loggers
  • I have added a third button to send an email with logs attached to a specified address (basically a mailto: URI)
  • I have added an option to have a flying debugger if embedded within a template (it requires changes in the template css however :s )

To do:

  • Make it work in jupyter. After pulling from master yesterday, it's not working in jupyter (trad and lab) anymore. I have unticked it from my first message.
  • (optionally) find a way to auto-test widgets within notebook if it's possible ; so that next time we don't need to manual test it.

There are still some problems with terminal itself where opening and closing the card. The text sometimes appear and sometimes disappear. Interestingly, exporting the log by clicking on the floppy disk button shows the full output even if the terminal is completely black. After testing a bit more, I will open a separate issue as it's not related to this widget but the interaction of Terminal & Card.

Besides the js console keeps complaining about the missing buttons when the card is closed. Not sure if a callback can be "deactivated" whenever the Card is closed so that we don't have the warning in the console.

@hyamanieu
Copy link
Collaborator Author

@philippjfr I have tested your changes. Very nice. I could not make sizing errors and the debugger now works in a jupyter context.

I have added a couple options (logging formatting + decide which logger to prompt) and fixed documentation.

I allowed myself to ping you for a review. There is a left over print, not sure this was wanted.

Besides the latter, to me it is ready to merge.

Thanks :)
ps: I'll add the "flying" effect and the mailing option at some point later. Current version works already well for end users to communicate clearly with dashboard developers.

@philippjfr philippjfr merged commit 162c693 into holoviz:master Apr 10, 2022
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

Successfully merging this pull request may close these issues.

Include a debug/info decorator
2 participants