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

Add show_debug notification #5101

Merged
merged 4 commits into from Feb 6, 2023
Merged

Add show_debug notification #5101

merged 4 commits into from Feb 6, 2023

Conversation

seankmartin
Copy link
Contributor

@seankmartin seankmartin commented Sep 19, 2022

Description

This PR is to add a show_debug notification function, to round out the existing functionality to show info, warning, and error.
I've been looking into plugin debugging in relation to #2948. I noticed that there was no show_debug function, which I thought might be a nice way to help debugging as the console log level preferences in napari can be set to info level to hide these.
Open to thoughts though if there is a reason it would be preferred not to have this function! I could use an alternative if so, outside of core, something like:

import napari
def alt_show_debug(message: str):
    napari.utils.notifications.notification_manager.dispatch(
        napari.utils.notifications.Notification(
            message, severity=napari.utils.notifications.NotificationSeverity.DEBUG
        )
    )

Type of change

  • New feature (non-breaking change which adds functionality)

References

Related to #2948 as I noticed it during writing this guide.

How has this been tested?

  • The test suite for my feature follows the structure for the existing show_x notification functionality

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • If I included new strings, I have used trans. to make them localizable.
    For more information see our translations guide.

@github-actions github-actions bot added the tests Something related to our tests label Sep 19, 2022
@github-actions
Copy link
Contributor

Click here to download the docs artifacts
docs
(zip file)

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #5101 (dce9466) into main (6bf6803) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5101   +/-   ##
=======================================
  Coverage   89.35%   89.36%           
=======================================
  Files         601      601           
  Lines       51153    51158    +5     
=======================================
+ Hits        45707    45716    +9     
+ Misses       5446     5442    -4     
Impacted Files Coverage Δ
napari/utils/_tests/test_notification_manager.py 100.00% <100.00%> (ø)
napari/utils/notifications.py 83.13% <100.00%> (+0.19%) ⬆️
napari/_qt/qt_viewer.py 78.78% <0.00%> (-0.21%) ⬇️
napari/_qt/dialogs/qt_package_installer.py 81.81% <0.00%> (+0.39%) ⬆️
napari/utils/theme.py 94.04% <0.00%> (+0.59%) ⬆️
napari/utils/info.py 85.10% <0.00%> (+1.06%) ⬆️
napari/_qt/__init__.py 56.66% <0.00%> (+6.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@kcpevey
Copy link
Contributor

kcpevey commented Dec 21, 2022

Thanks @seankmartin for this PR!

I'm adding @brisvag or @Czaki as reviewers since it seems this went overlooked. If there is someone else who would be better to review, feel free to swap!

@brisvag
Copy link
Contributor

brisvag commented Dec 21, 2022

Good, seems pretty straightforward to me. I'm not sure I understand how to enable/disable this when actually using napari. Is the default loglevel WARN?

@seankmartin
Copy link
Contributor Author

As I understand it (please correct me if wrong!)

There are two default log levels set here

gui_notification_level: NotificationSeverity = Field(
NotificationSeverity.INFO,
title=trans._("GUI notification level"),
description=trans._(
"Select the notification level for the user interface."
),
)
console_notification_level: NotificationSeverity = Field(
NotificationSeverity.NONE,
title=trans._("Console notification level"),
description=trans._("Select the notification level for the console."),
)

  1. gui_notification_level - by default info.
  2. console_notification_level - by default none (so it prints every log message).

By default show_debug(msg) would print to console, but not show it in the GUI message popup box in the bottom right of the viewer.

To change the level in napari and see the show_debug output, you can directly set it

settings = napari.get_settings()
settings.application.console_notification_level = "debug"
settings.application.gui_notification_level = "debug"

Or if using the GUI, you can set it in Preferences -> Application -> GUI notification level / Console notification level.

Copy link
Contributor

@brisvag brisvag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the rundown! Seems useful to me :)

@Czaki Czaki added the feature New feature or request label Feb 5, 2023
@Czaki Czaki added this to the 0.5.0 milestone Feb 5, 2023
@brisvag brisvag merged commit 7696409 into napari:main Feb 6, 2023
kne42 added a commit to kne42/napari that referenced this pull request Feb 28, 2023
* main: (38 commits)
  Fix `test_worker_with_progress` by wait on worker end (napari#5548)
  Un-set unified title and tool bar on mac (Qt property) (napari#5533)
  Set PYTHONEXECUTABLE as part of macos fixes on (re)startup (napari#5531)
  Fix key error issue of action manager (napari#5539)
  Clean dangling widget in test (napari#5544)
  Use pytest-pretty for better log readability (napari#5525)
  Update vendoring tool to check on matplotlib colormap (napari#5181)
  MAINT: add time limit for CI. (napari#5495)
  Add show_debug notification (napari#5101)
  Overlays 2.0 (napari#4894)
  Clarify layer's editable property and separate interaction with visible property (napari#5413)
  ci(dependabot): bump docker/build-push-action from 3 to 4 (napari#5523)
  Fix opening file dialogs in PySide (napari#5492)
  [pre-commit.ci] pre-commit autoupdate (napari#5518)
  Replace flake8, isort and pyupgrade by ruff, enable additional usefull rules (napari#5513)
  MAINT: Don't format logs in log call (napari#5504)
  Fix conda avaliability check (napari#5496)
  Handle case when QtDims play thread is partially deleted (napari#5499)
  Bugfix: Add missing Enums and Flags required by PySide6 > 6.4 (napari#5480)
  Refactor Main Window status bar to improve information presentation (napari#5451)
  ...
@Czaki Czaki modified the milestones: 0.5.0, 0.4.19 Nov 13, 2023
Czaki pushed a commit that referenced this pull request Nov 13, 2023
Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants