Skip to content

Commit

Permalink
Change 'Kedro Viz' to 'Kedro Viz Run' (#1671)
Browse files Browse the repository at this point in the history
* test viz group initial draft

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update viz group help text

Signed-off-by: ravi-kumar-pilla <[email protected]>

* add pytest

Signed-off-by: ravi-kumar-pilla <[email protected]>

* fix e2e tests

Signed-off-by: ravi-kumar-pilla <[email protected]>

* Add new notes for upcoming release

Signed-off-by: mehdinv <[email protected]>

* Correct typo in RELEASE file

Mistakenly wrote 'kedro run' instead of 'kedro viz' - commit changes it to be the latter

Co-authored-by: Merel Theisen <[email protected]>

* Remove redundant bullet point in RELEASE.md

Signed-off-by: mehdinv <[email protected]>

* Remove redundant command deploy from group

Signed-off-by: mehdinv <[email protected]>

* Adjust doc refs of 'kedro viz' to 'kedro viz run'

Signed-off-by: mehdinv <[email protected]>

* Update more doc references to 'kedro viz run'

Signed-off-by: mehdinv <[email protected]>

* remove custom command group class

Signed-off-by: ravi-kumar-pilla <[email protected]>

---------

Signed-off-by: ravi-kumar-pilla <[email protected]>
Signed-off-by: mehdinv <[email protected]>
Co-authored-by: ravi-kumar-pilla <[email protected]>
Co-authored-by: Merel Theisen <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2023
1 parent 9fb0e85 commit b9b0a96
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 54 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ For **Python 3.6** users, the last supported version of Kedro-Viz is **3.16.0**
To launch Kedro-Viz from the command line as a Kedro plugin, use the following command from the root folder of your Kedro project:

```bash
kedro viz
kedro viz run
```

A browser tab opens automatically to serve the visualisation at `http://127.0.0.1:4141/`.

Kedro-Viz also supports the following additional arguments on the command line:

```bash
Usage: kedro viz [OPTIONS]
Usage: kedro viz run [OPTIONS]

Visualise a Kedro pipeline using Kedro-Viz.

Expand Down Expand Up @@ -183,7 +183,7 @@ const MyApp = () => <NoSSRKedro data={json} />;
The JSON can be obtained by running:
```bash
kedro viz --save-file=filename.json
kedro viz run --save-file=filename.json
```
We also recommend wrapping the `Kedro-Viz` component with a parent HTML/JSX element that has a specified height (as seen in the above example) in order for Kedro-Viz to be styled properly.
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Please follow the established format:

- Fix for dataset existence check in factory pattern discovery (#1659)
- Remove support for Python 3.7 (#1660)
- Adjust CLI to use 'kedro viz run' instead of 'kedro viz' (#1671)

# Release 6.7.0

Expand Down
2 changes: 1 addition & 1 deletion demo-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ This project is designed to be a realistic example of what Kedro looks like when
1. Run `pip install kedro~=0.18.0`
2. Run `pip install -r src/demo_project/requirements.in`
3. Run `kedro run`
4. Run `kedro viz`
4. Run `kedro viz run`
4 changes: 2 additions & 2 deletions docs/source/experiment_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Execute `kedro run` a few times in a row to generate a larger set of experiment
Here comes the fun part of accessing your run data on Kedro-Viz. Having generated some run data, execute the following command:

```bash
kedro viz
kedro viz run
```

When you open the Kedro-Viz web app, you see an experiment tracking icon on the left-hand side of the screen.
Expand Down Expand Up @@ -323,7 +323,7 @@ confusion_matrix:
versioned: true
```

After running the pipeline with `kedro run`, the plot is saved and you can see it in the experiment tracking panel when you execute `kedro viz`. Clicking on a plot expands it. When in comparison view, expanding a plot shows all the plots in that view for side-by-side comparison.
After running the pipeline with `kedro run`, the plot is saved and you can see it in the experiment tracking panel when you execute `kedro viz run`. Clicking on a plot expands it. When in comparison view, expanding a plot shows all the plots in that view for side-by-side comparison.

![](./images/experiment-tracking-plots-comparison.png)

Expand Down
12 changes: 6 additions & 6 deletions docs/source/kedro-viz_visualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ kedro run
To start Kedro-Viz, type the following into your terminal from the project directory:

```bash
kedro viz
kedro viz run
```

```{important}
The `kedro viz` command will be deprecated with the release of Kedro-Viz 7.0.0.
`kedro viz run` will be the new way to run the tool.
The former `kedro viz` command used here is now deprecated with the release of Kedro-Viz 7.0.0.
`kedro viz run` is now the new way to run the tool.
```

The command opens a browser tab to serve the visualisation at `http://127.0.0.1:4141/`.
Expand All @@ -59,7 +59,7 @@ To exit the visualisation, close the browser tab. To regain control of the termi
You can use the `--autoreload` flag to autoreload Kedro-Viz when a `Python` or `YAML` file changes in the project. Add the flag to the command you use to start Kedro-Viz:

```bash
kedro viz --autoreload
kedro viz run --autoreload
```

![](./images/kedro_viz_autoreload.gif)
Expand Down Expand Up @@ -162,15 +162,15 @@ The visualisation now includes the layers:
You can share a pipeline structure within a Kedro-Viz visualisation as a JSON file from the terminal:

```bash
kedro viz --save-file=my_shareable_pipeline.json
kedro viz run --save-file=my_shareable_pipeline.json
```

This command will save a visualisation of the `__default__` pipeline as a JSON file called `my_shareable_pipeline.json`. It doesn't share data, such as that in the code panel, nor can you share images or charts.

To visualise the shared file, type the following to load it from the terminal:

```bash
kedro viz --load-file=my_shareable_pipeline.json
kedro viz run --load-file=my_shareable_pipeline.json
```

You can also share a complete project visualisation, described in more detail on [the following page](./share_kedro_viz).
2 changes: 1 addition & 1 deletion docs/source/preview_datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ shuttles:
After you've configured the Data Catalog, you can preview the datasets on Kedro-Viz. Start Kedro-Viz by running the following command in your terminal:
```bash
kedro viz
kedro viz run
```

The previews are shown as follows:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/share_kedro_viz.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For more information, see the official AWS documentation about [how to work with
You're now ready to publish and share your Kedro-Viz project. Start Kedro-Viz by running the following command in your terminal:

```bash
kedro viz
kedro viz run
```

Click the **Publish and share** icon in the lower-left of the application. You will see a modal dialog to select your relevant AWS Bucket Region and enter your Bucket Name.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/visualise_charts_with_matplotlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_pipeline(**kwargs) -> Pipeline:

## Run the pipeline

Run the pipelines with `kedro run` and then visualise the result with `kedro viz`.
Run the pipelines with `kedro run` and then visualise the result with `kedro viz run`.

Click to see a small preview of the Matplotlib image in the metadata panel.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/visualise_charts_with_plotly.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Now run the pipelines:
kedro run
```

Then visualise with `kedro viz`
Then visualise with `kedro viz run`

The generated charts are shown as follows:

Expand Down
2 changes: 1 addition & 1 deletion package/features/steps/cli_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def install_kedro(context, version):
def exec_viz_command(context):
"""Execute Kedro-Viz command."""
context.result = ChildTerminatingPopen(
[context.kedro, "viz", "--no-browser"],
[context.kedro, "viz", "run", "--no-browser"],
env=context.env,
cwd=str(context.root_project_dir),
)
Expand Down
30 changes: 18 additions & 12 deletions package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@


@click.group(name="Kedro-Viz")
def commands(): # pylint: disable=missing-function-docstring
def viz_cli(): # pylint: disable=missing-function-docstring
pass


@commands.command(context_settings={"help_option_names": ["-h", "--help"]})
@viz_cli.group(invoke_without_command=True)
@click.pass_context
def viz(ctx):
"""Visualise a Kedro pipeline using Kedro viz."""
if ctx.invoked_subcommand is None:
click.echo(
click.style(
"\nDid you mean this ? \n kedro viz run \n\n",
fg="yellow",
)
)
click.echo(click.style(f"{ctx.get_help()}"))


@viz.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.option(
"--host",
default=DEFAULT_HOST,
Expand Down Expand Up @@ -89,7 +103,7 @@ def commands(): # pylint: disable=missing-function-docstring
callback=_split_params,
)
# pylint: disable=import-outside-toplevel, too-many-locals
def viz(
def run(
host,
port,
browser,
Expand All @@ -101,7 +115,7 @@ def viz(
ignore_plugins,
params,
):
"""Visualise a Kedro pipeline using Kedro viz."""
"""Launch local Kedro Viz instance"""
from kedro_viz.server import run_server

installed_version = parse(__version__)
Expand All @@ -119,14 +133,6 @@ def viz(
),
)

click.echo(
click.style(
"WARNING: The `kedro viz` command will be deprecated with the release of "
"Kedro-Viz 7.0.0. `kedro viz run` will be the new way to run the tool.",
fg="yellow",
),
)

try:
if port in _VIZ_PROCESSES and _VIZ_PROCESSES[port].is_alive():
_VIZ_PROCESSES[port].terminate()
Expand Down
2 changes: 1 addition & 1 deletion package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
package_data={"kedro_viz": list(files)},
zip_safe=False,
entry_points={
"kedro.global_commands": ["kedro-viz = kedro_viz.launchers.cli:commands"],
"kedro.global_commands": ["kedro-viz = kedro_viz.launchers.cli:viz_cli"],
"kedro.line_magic": ["line_magic = kedro_viz.launchers.jupyter:run_viz"],
"kedro.hooks": [
"kedro-dataset-stats = kedro_viz.integrations.kedro.hooks:dataset_stats_hook"
Expand Down
56 changes: 32 additions & 24 deletions package/tests/test_launchers/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def patched_start_browser(mocker):
"command_options,run_server_args",
[
(
["viz"],
["viz", "run"],
{
"host": "127.0.0.1",
"port": 4141,
Expand All @@ -41,6 +41,7 @@ def patched_start_browser(mocker):
(
[
"viz",
"run",
"--host",
"localhost",
],
Expand All @@ -59,6 +60,7 @@ def patched_start_browser(mocker):
(
[
"viz",
"run",
"--host",
"8.8.8.8",
"--port",
Expand Down Expand Up @@ -86,7 +88,7 @@ def patched_start_browser(mocker):
},
),
(
["viz", "--ignore-plugins"],
["viz", "run", "--ignore-plugins"],
{
"host": "127.0.0.1",
"port": 4141,
Expand Down Expand Up @@ -114,7 +116,7 @@ def test_kedro_viz_command_run_server(
mocker.patch("kedro_viz.launchers.cli._wait_for.__defaults__", (True, 1, True, 1))

with runner.isolated_filesystem():
runner.invoke(cli.commands, command_options)
runner.invoke(cli.viz_cli, command_options)

process_init.assert_called_once_with(
target=run_server, daemon=False, kwargs={**run_server_args}
Expand All @@ -134,7 +136,7 @@ def test_kedro_viz_command_should_log_outdated_version(mocker, mock_http_respons
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
runner.invoke(cli.viz_cli, ["viz", "run"])

mock_click_echo_calls = [
call(
Expand All @@ -144,11 +146,7 @@ def test_kedro_viz_command_should_log_outdated_version(mocker, mock_http_respons
"You should consider upgrading via the `pip install -U kedro-viz` command.\n"
"You can view the complete changelog at "
"https://github.com/kedro-org/kedro-viz/releases.\x1b[0m"
),
call(
"\x1b[33mWARNING: The `kedro viz` command will be deprecated with the release of "
"Kedro-Viz 7.0.0. `kedro viz run` will be the new way to run the tool.\x1b[0m",
),
)
]

mock_click_echo.assert_has_calls(mock_click_echo_calls)
Expand All @@ -164,14 +162,9 @@ def test_kedro_viz_command_should_not_log_latest_version(mocker, mock_http_respo
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
runner.invoke(cli.viz_cli, ["viz", "run"])

mock_click_echo_calls = [
call(
"\x1b[33mWARNING: The `kedro viz` command will be deprecated with the release of "
"Kedro-Viz 7.0.0. `kedro viz run` will be the new way to run the tool.\x1b[0m",
)
]
mock_click_echo_calls = [call("\x1b[32mStarting Kedro Viz ...\x1b[0m")]

mock_click_echo.assert_has_calls(mock_click_echo_calls)

Expand All @@ -184,14 +177,9 @@ def test_kedro_viz_command_should_not_log_if_pypi_is_down(mocker, mock_http_resp
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
runner.invoke(cli.viz_cli, ["viz", "run"])

mock_click_echo_calls = [
call(
"\x1b[33mWARNING: The `kedro viz` command will be deprecated with the release of "
"Kedro-Viz 7.0.0. `kedro viz run` will be the new way to run the tool.\x1b[0m",
)
]
mock_click_echo_calls = [call("\x1b[32mStarting Kedro Viz ...\x1b[0m")]

mock_click_echo.assert_has_calls(mock_click_echo_calls)

Expand All @@ -206,7 +194,7 @@ def test_kedro_viz_command_with_autoreload(
mocker.patch("kedro_viz.launchers.cli._wait_for.__defaults__", (True, 1, True, 1))
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz", "--autoreload"])
runner.invoke(cli.viz_cli, ["viz", "run", "--autoreload"])

run_process_kwargs = {
"path": mock_project_path,
Expand All @@ -231,3 +219,23 @@ def test_kedro_viz_command_with_autoreload(
target=run_process, daemon=False, kwargs={**run_process_kwargs}
)
assert run_process_kwargs["kwargs"]["port"] in cli._VIZ_PROCESSES


def test_kedro_viz_command_group(mocker):
mock_click_echo = mocker.patch("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 run Launch local Kedro Viz instance\x1b[0m"
),
]

mock_click_echo.assert_has_calls(mock_click_echo_calls)

0 comments on commit b9b0a96

Please sign in to comment.