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

Kedro CLI startup time made shorter #1196

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Please follow the established format:

- Allow users to hide modular pipelines on the flowchart. (#1046)
- Create URL parameters for each element/section in the flowchart. (#1138)
- Improve CLI loading time. (#1196)

## Bug fixes and other changes

Expand Down
3 changes: 3 additions & 0 deletions package/kedro_viz/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
DEFAULT_REGISTERED_PIPELINE_ID = "__default__"
KEDRO_VERSION = VersionInfo.parse(kedro.__version__)
ROOT_MODULAR_PIPELINE_ID = "__root__"

DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 4141
5 changes: 4 additions & 1 deletion package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from watchgod import RegExpWatcher, run_process

from kedro_viz import __version__
from kedro_viz.constants import DEFAULT_HOST, DEFAULT_PORT
from kedro_viz.integrations.pypi import get_latest_version, is_running_outdated_version
from kedro_viz.server import DEFAULT_HOST, DEFAULT_PORT, is_localhost, run_server


@click.group(name="Kedro-Viz")
Expand Down Expand Up @@ -80,8 +80,11 @@ def commands(): # pylint: disable=missing-function-docstring
help=PARAMS_ARG_HELP,
callback=_split_params,
)
# pylint: disable=import-outside-toplevel, too-many-locals
def viz(host, port, browser, load_file, save_file, pipeline, env, autoreload, params):
"""Visualise a Kedro pipeline using Kedro viz."""
from kedro_viz.server import is_localhost, run_server

installed_version = VersionInfo.parse(__version__)
latest_version = get_latest_version()

Expand Down
3 changes: 1 addition & 2 deletions package/kedro_viz/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

from kedro_viz.api import apps
from kedro_viz.api.rest.responses import EnhancedORJSONResponse, get_default_response
from kedro_viz.constants import DEFAULT_HOST, DEFAULT_PORT
from kedro_viz.data_access import DataAccessManager, data_access_manager
from kedro_viz.database import create_db_engine
from kedro_viz.integrations.kedro import data_loader as kedro_data_loader
from kedro_viz.models.experiment_tracking import Base

DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 4141
DEV_PORT = 4142


Expand Down
11 changes: 6 additions & 5 deletions package/tests/test_launchers/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from kedro_viz import __version__
from kedro_viz.launchers import cli
from kedro_viz.server import run_server


@pytest.mark.parametrize(
Expand Down Expand Up @@ -57,7 +58,7 @@
],
)
def test_kedro_viz_command_run_server(command_options, run_server_args, mocker):
run_server = mocker.patch("kedro_viz.launchers.cli.run_server")
run_server = mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, command_options)
Expand All @@ -74,7 +75,7 @@ def test_kedro_viz_command_should_log_outdated_version(mocker, mock_http_respons
)
mock_click_echo = mocker.patch("click.echo")

mocker.patch("kedro_viz.launchers.cli.run_server")
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
Expand All @@ -96,7 +97,7 @@ def test_kedro_viz_command_should_not_log_latest_version(mocker, mock_http_respo
)
mock_click_echo = mocker.patch("click.echo")

mocker.patch("kedro_viz.launchers.cli.run_server")
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
Expand All @@ -109,7 +110,7 @@ def test_kedro_viz_command_should_not_log_if_pypi_is_down(mocker, mock_http_resp
requests_get.side_effect = requests.exceptions.RequestException("PyPI is down")
mock_click_echo = mocker.patch("click.echo")

mocker.patch("kedro_viz.launchers.cli.run_server")
mocker.patch("kedro_viz.server.run_server")
runner = CliRunner()
with runner.isolated_filesystem():
runner.invoke(cli.commands, ["viz"])
Expand All @@ -128,7 +129,7 @@ def test_kedro_viz_command_with_autoreload(mocker):

run_process.assert_called_once_with(
path=mock_project_path,
target=cli.run_server,
target=run_server,
kwargs={
"host": "127.0.0.1",
"port": 4141,
Expand Down