Skip to content

Commit

Permalink
Make kedro viz also do what kedro viz run does (#1790)
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
  • Loading branch information
deepyaman authored Mar 7, 2024
1 parent 3eeb565 commit 1ff461d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Please follow the established format:

- Fix a bug on metadata panel when preview data is unavailable. (#1794)
- Update Compatibility/Support Matrix in README. (#1774)
- Update CLI command to support both `kedro viz run` and `kedro viz`. (#1790)

# Release 8.0.0

Expand Down
8 changes: 3 additions & 5 deletions package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Dict

import click
from click_default_group import DefaultGroup
from kedro.framework.cli.project import PARAMS_ARG_HELP
from kedro.framework.cli.utils import KedroCliError, _split_params
from packaging.version import parse
Expand Down Expand Up @@ -41,13 +42,10 @@ def viz_cli(): # pylint: disable=missing-function-docstring
pass


@viz_cli.group(invoke_without_command=True)
@viz_cli.group(cls=DefaultGroup, default="run", default_if_no_args=True)
@click.pass_context
def viz(ctx):
def viz(ctx): # pylint: disable=unused-argument
"""Visualise a Kedro pipeline using Kedro viz."""
if ctx.invoked_subcommand is None:
display_cli_message("\nDid you mean this ? \n kedro viz run \n\n", "yellow")
display_cli_message(f"{ctx.get_help()}")


@viz.command(context_settings={"help_option_names": ["-h", "--help"]})
Expand Down
21 changes: 11 additions & 10 deletions package/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
packaging~=23.0
kedro>=0.18.0
ipython>=7.0.0, <9.0
aiofiles>=22.1.0
click-default-group
fastapi>=0.100.0,<0.200.0
fsspec>=2021.4
aiofiles>=22.1.0
uvicorn[standard]~=0.27.1
watchgod~=0.8.2
plotly>=4.0
pandas>=1.3
sqlalchemy>=1.4, <3
strawberry-graphql>=0.192.0, <1.0
ipython>=7.0.0, <9.0
kedro>=0.18.0
networkx>=2.5
orjson~=3.9
packaging~=23.0
pandas>=1.3
plotly>=4.0
secure>=0.3.0
sqlalchemy>=1.4, <3
strawberry-graphql>=0.192.0, <1.0
uvicorn[standard]~=0.27.1
watchgod~=0.8.2
45 changes: 29 additions & 16 deletions package/tests/test_launchers/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ def mock_project_path(mocker):
@pytest.mark.parametrize(
"command_options,run_server_args",
[
(
["viz"],
{
"host": "127.0.0.1",
"port": 4141,
"load_file": None,
"save_file": None,
"pipeline_name": None,
"env": None,
"autoreload": False,
"ignore_plugins": False,
"extra_params": {},
},
),
(
["viz", "run"],
{
Expand Down Expand Up @@ -279,22 +293,21 @@ def test_viz_command_group(mocker, mock_click_echo):
runner = CliRunner()

with runner.isolated_filesystem():
runner.invoke(cli.viz_cli, ["viz"])

mock_click_echo_calls = [
call("\x1b[33m\nDid you mean this ? \n kedro viz run \n\n\x1b[0m"),
call(
"Usage: Kedro-Viz viz [OPTIONS] COMMAND [ARGS]...\n\n "
"Visualise a Kedro pipeline using Kedro viz.\n\n"
"Options:\n --help Show this message and exit.\n\n"
"Commands:\n build Create build directory of local Kedro Viz "
"instance with Kedro...\n "
"deploy Deploy and host Kedro Viz on provided platform\n "
"run Launch local Kedro Viz instance\x1b[0m"
),
]

mock_click_echo.assert_has_calls(mock_click_echo_calls)
result = runner.invoke(cli.viz_cli, ["viz", "--help"])

assert result.output == (
"Usage: Kedro-Viz viz [OPTIONS] COMMAND [ARGS]...\n"
"\n"
" Visualise a Kedro pipeline using Kedro viz.\n"
"\n"
"Options:\n"
" --help Show this message and exit.\n"
"\n"
"Commands:\n"
" run* Launch local Kedro Viz instance\n"
" build Create build directory of local Kedro Viz instance with Kedro...\n"
" deploy Deploy and host Kedro Viz on provided platform\n"
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 1ff461d

Please sign in to comment.