Skip to content

Commit

Permalink
Disable watchdog suggestion for none or poll watcher type (#8024)
Browse files Browse the repository at this point in the history
* Disables watchdog suggestion for none or poll watcher type

* Add tests
  • Loading branch information
LukasMasuch committed Jan 26, 2024
1 parent 27ebb82 commit f4684e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/streamlit/watcher/path_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def __init__(

def report_watchdog_availability():
if not watchdog_available:
if not config.get_option("global.disableWatchdogWarning"):
if not config.get_option("global.disableWatchdogWarning") and config.get_option(
"server.fileWatcherType"
) not in ["poll", "none"]:
msg = "\n $ xcode-select --install" if env_util.IS_DARWIN else ""

click.secho(
Expand Down
20 changes: 20 additions & 0 deletions lib/tests/streamlit/watcher/path_watcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ def test_report_watchdog_availability_mac(self):
]
mock_echo.assert_has_calls(calls)

@patch_config_options({"server.fileWatcherType": "poll"})
def test_no_watchdog_suggestion_for_poll_type(self):
with patch(
"streamlit.watcher.path_watcher.watchdog_available", new=False
), patch("streamlit.env_util.IS_DARWIN", new=False), patch(
"click.secho"
) as mock_echo:
streamlit.watcher.path_watcher.report_watchdog_availability()
mock_echo.assert_not_called()

@patch_config_options({"server.fileWatcherType": "none"})
def test_no_watchdog_suggestion_for_none_type(self):
with patch(
"streamlit.watcher.path_watcher.watchdog_available", new=False
), patch("streamlit.env_util.IS_DARWIN", new=False), patch(
"click.secho"
) as mock_echo:
streamlit.watcher.path_watcher.report_watchdog_availability()
mock_echo.assert_not_called()

def test_report_watchdog_availability_nonmac(self):
with patch(
"streamlit.watcher.path_watcher.watchdog_available", new=False
Expand Down

0 comments on commit f4684e2

Please sign in to comment.