From 8cb722b9b35bb73254bf8dc48374b1c23ea2c403 Mon Sep 17 00:00:00 2001 From: philippe Date: Tue, 3 May 2022 16:29:33 -0400 Subject: [PATCH 1/7] Add start_timeout to threaded test server, set to 3 seconds, log thread exceptions. --- dash/testing/application_runners.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dash/testing/application_runners.py b/dash/testing/application_runners.py index deaa197f8c..4ce07b8aff 100644 --- a/dash/testing/application_runners.py +++ b/dash/testing/application_runners.py @@ -142,8 +142,13 @@ def __init__(self, keep_open=False, stop_timeout=3): super().__init__(keep_open=keep_open, stop_timeout=stop_timeout) self.thread = None + def running_and_accessible(self, url): + if self.thread.is_alive(): + return self.accessible(url) + raise DashAppLoadingError("Thread is not alive.") + # pylint: disable=arguments-differ - def start(self, app, **kwargs): + def start(self, app, start_timeout=3, **kwargs): """Start the app server in threading flavor.""" def _handle_error(): @@ -151,9 +156,6 @@ def _handle_error(): app.server.errorhandler(500)(_handle_error) - if self.thread and self.thread.is_alive(): - self.stop() - def run(): app.scripts.config.serve_locally = True app.css.config.serve_locally = True @@ -170,16 +172,24 @@ def run(): app.run(threaded=True, **options) except SystemExit: logger.info("Server stopped") + except Exception as error: + logger.exception(error) + raise error retries = 0 while not self.started and retries < 3: try: + if self.thread and self.thread.is_alive(): + self.stop() + self.thread = KillerThread(target=run) self.thread.daemon = True self.thread.start() # wait until server is able to answer http request - wait.until(lambda: self.accessible(self.url), timeout=2) + wait.until( + lambda: self.running_and_accessible(self.url), timeout=start_timeout + ) self.started = self.thread.is_alive() except Exception as err: # pylint: disable=broad-except logger.exception(err) From 21bfef3c368e5e58415ca85ff183c077e167fe27 Mon Sep 17 00:00:00 2001 From: philippe Date: Tue, 3 May 2022 17:07:00 -0400 Subject: [PATCH 2/7] noise From 6b538f3227b725ac7bc0522ad5341dcc28c0930a Mon Sep 17 00:00:00 2001 From: philippe Date: Tue, 3 May 2022 17:36:05 -0400 Subject: [PATCH 3/7] noise From 32f82ce58270b1a44793a73da2730d5d816feb61 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 4 May 2022 09:37:55 -0400 Subject: [PATCH 4/7] noise From 51b93b9d7295f716be8d37fc93c4411b8b08c1f1 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 4 May 2022 10:12:41 -0400 Subject: [PATCH 5/7] Add type annotations to dash testing fixtures. --- dash/testing/plugin.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dash/testing/plugin.py b/dash/testing/plugin.py index 33cac6e292..2fd5b7a21c 100644 --- a/dash/testing/plugin.py +++ b/dash/testing/plugin.py @@ -95,33 +95,33 @@ def pytest_runtest_makereport(item, call): # pylint: disable=unused-argument @pytest.fixture -def dash_thread_server(): +def dash_thread_server() -> ThreadedRunner: """Start a local dash server in a new thread.""" with ThreadedRunner() as starter: yield starter @pytest.fixture -def dash_process_server(): +def dash_process_server() -> ProcessRunner: """Start a Dash server with subprocess.Popen and waitress-serve.""" with ProcessRunner() as starter: yield starter @pytest.fixture -def dashr_server(): +def dashr_server() -> RRunner: with RRunner() as starter: yield starter @pytest.fixture -def dashjl_server(): +def dashjl_server() -> JuliaRunner: with JuliaRunner() as starter: yield starter @pytest.fixture -def dash_br(request, tmpdir): +def dash_br(request, tmpdir) -> Browser: with Browser( browser=request.config.getoption("webdriver"), remote=request.config.getoption("remote"), @@ -137,7 +137,7 @@ def dash_br(request, tmpdir): @pytest.fixture -def dash_duo(request, dash_thread_server, tmpdir): +def dash_duo(request, dash_thread_server, tmpdir) -> DashComposite: with DashComposite( dash_thread_server, browser=request.config.getoption("webdriver"), @@ -154,7 +154,7 @@ def dash_duo(request, dash_thread_server, tmpdir): @pytest.fixture -def dashr(request, dashr_server, tmpdir): +def dashr(request, dashr_server, tmpdir) -> DashRComposite: with DashRComposite( dashr_server, browser=request.config.getoption("webdriver"), @@ -171,7 +171,7 @@ def dashr(request, dashr_server, tmpdir): @pytest.fixture -def dashjl(request, dashjl_server, tmpdir): +def dashjl(request, dashjl_server, tmpdir) -> DashJuliaComposite: with DashJuliaComposite( dashjl_server, browser=request.config.getoption("webdriver"), From a1ef12d3c3c0a4a4c26dd1ead36e57bd15faa795 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 4 May 2022 10:27:45 -0400 Subject: [PATCH 6/7] Update changelog. --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c7c9745ba..0aa49dea96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). - [#2034](https://github.com/plotly/dash/pull/2034) Add `link_target` prop to dcc.Markdown component. Closes [#1827](https://github.com/plotly/dash/issues/1827) +- [#2035](https://github.com/plotly/dash/pull/2036) Add type annotations to testing fixtures. + ### Fixed - [#2029](https://github.com/plotly/dash/pull/2029) Restrict the number of props listed explicitly in generated component constructors - default is 250. This prevents exceeding the Python 3.6 limit of 255 arguments. The omitted props are still in the docstring and can still be provided the same as before, they just won't appear in the signature so autocompletion may be affected. @@ -30,6 +32,10 @@ This project adheres to [Semantic Versioning](https://semver.org/). - [#2035](https://github.com/plotly/dash/pull/2035) Fix [#2033](https://github.com/plotly/dash/issues/2033) In-App error reporting does not render HTML. +- [#1970](https://github.com/plotly/dash/pull/1970) dcc.Dropdown Refactor fixes: + - Fix bug [#1868](https://github.com/plotly/dash/issues/1868) value does not update when selected option removed from options. + - Fix bug [#1908](https://github.com/plotly/dash/issues/1908) Selected options not showing when the value contains a comma. + ### Changed - [#2016](https://github.com/plotly/dash/pull/2016) Drop the 375px width from default percy_snapshot calls, keep only 1280px @@ -46,11 +52,6 @@ This project adheres to [Semantic Versioning](https://semver.org/). - Upgrade `black` to v22.3.0 for Python 3.7+ - if you use `dash[ci]` and you call `black`, this may alter your code formatting slightly, including more consistently breaking Python 2 compatibility. - Many other mainly JS dependency upgrades to the internals of Dash renderer and components. These may patch bugs or improve performance. -### Fixed - -- [#1970](https://github.com/plotly/dash/pull/1970) dcc.Dropdown Refactor fixes: - - Fix bug [#1868](https://github.com/plotly/dash/issues/1868) value does not update when selected option removed from options. - - Fix bug [#1908](https://github.com/plotly/dash/issues/1908) Selected options not showing when the value contains a comma. ## [2.3.1] - 2022-03-29 From 33363e9e4eec9a908190611834cc138ed801ec37 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 4 May 2022 10:54:25 -0400 Subject: [PATCH 7/7] noise