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

(KED-1516) Stop kedro-viz from swallowing stacktraces #142

Merged
merged 5 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Please follow the established format:
- Drop support for Python 3.5 (#138)
- Add logger configuration when loading pipeline from JSON (#133)
- Move visibleNav/navWidth calculations into Redux store (#124)
- Web browser will only be opened if the host corresponds to the localhost
- Web browser will only be opened if the host corresponds to the localhost (#136)
- Print the stack trace when encountering a generic exception (#142)

## Thanks for supporting contributions

Expand Down
2 changes: 2 additions & 0 deletions package/kedro_viz/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import logging
import multiprocessing
import socket
import traceback
import webbrowser
from collections import defaultdict
from contextlib import closing
Expand Down Expand Up @@ -305,6 +306,7 @@ def viz(host, port, browser, load_file, save_file, pipeline, env):
except KedroCliError:
raise
except Exception as ex:
traceback.print_exc()
raise KedroCliError(str(ex))


Expand Down
14 changes: 13 additions & 1 deletion package/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def test_no_browser_if_not_localhost(cli_runner):
"""Check that call to open browser is not performed when host
is not the local host.
"""
result = cli_runner.invoke(server.commands, ["viz", "--browser", "--host", "123.1.2.3"])
result = cli_runner.invoke(
server.commands, ["viz", "--browser", "--host", "123.1.2.3"]
)
assert result.exit_code == 0, result.output
assert not server.webbrowser.open_new.called
result = cli_runner.invoke(server.commands, ["viz", "--host", "123.1.2.3"])
Expand Down Expand Up @@ -385,6 +387,16 @@ def test_viz_kedro14_invalid(mocker, cli_runner):
assert "Could not find a Kedro project root." in result.output


def test_viz_stacktrace(mocker, cli_runner):
"""Test that in the case of a generic exception,
the stacktrace is printer."""
mzjp2 marked this conversation as resolved.
Show resolved Hide resolved
mocker.patch("kedro_viz.server._call_viz", side_effect=ValueError)
result = cli_runner.invoke(server.commands, "viz")

assert "Traceback (most recent call last):" in result.output
assert "ValueError" in result.output


@pytest.fixture(autouse=True)
def clean_up():
# pylint: disable=protected-access
Expand Down