Skip to content

Commit

Permalink
fix: logger message to debug when plugins not found (#995)
Browse files Browse the repository at this point in the history
* fix: logger message to debug when plugins not found

* add changelog and test

* fix:lint error

* fix:lint error

* amend test and log format

---------

Co-authored-by: Anca Lita <[email protected]>
  • Loading branch information
souvikg10 and ancalita authored Jul 11, 2023
1 parent a6c7a9a commit 2caaa67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/1219.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The logger for rasa_sdk plugin will not throw traceback when no plugins are found since plugins are optional. It will be only available in debug mode, however the action server will continue to run.
2 changes: 1 addition & 1 deletion rasa_sdk/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _discover_plugins(manager: pluggy.PluginManager) -> None:

rasa_sdk_plugins.init_hooks(manager)
except ModuleNotFoundError as e:
logger.info("No plugins found", exc_info=e)
logger.debug("No plugins found: %s", e)
pass


Expand Down
13 changes: 12 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import logging
import warnings

from pytest import MonkeyPatch
from pytest import MonkeyPatch, LogCaptureFixture
from pluggy import PluginManager
from unittest.mock import MagicMock

from rasa_sdk import endpoint
from rasa_sdk.plugin import plugin_manager


def test_plugins_not_found(caplog: LogCaptureFixture) -> None:
"""Test that a debug message is logged when no plugins are found.
This test must be run first because the plugin manager is cached.
"""
with caplog.at_level(logging.DEBUG):
plugin_manager()
assert "No plugins found: No module named 'rasa_sdk_plugins'" in caplog.text


def test_plugin_manager() -> None:
manager = plugin_manager()
assert isinstance(manager, PluginManager)
Expand Down

0 comments on commit 2caaa67

Please sign in to comment.