Skip to content

Commit

Permalink
Display hosted URL in CLI while launching kedro viz (#1644)
Browse files Browse the repository at this point in the history
* add url to cli run

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

* test 0.18.2 kedro e2e

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

* test pip version

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

* upgrade pip

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

* adjust dependencies

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

* add release note

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

* fix review comments

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

* replace print with click echo

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

---------

Signed-off-by: ravi-kumar-pilla <[email protected]>
  • Loading branch information
ravi-kumar-pilla authored Dec 4, 2023
1 parent f5e3bfb commit 8fa95a1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Please follow the established format:
- Use present tense (e.g. 'Add new feature')
- Include the ID number for the related PR (or PRs) in parentheses
-->
# Upcoming Release

## Major features and improvements

- Display hosted URL in CLI while launching kedro viz. (#1644)

# Release 6.7.0

Expand Down
16 changes: 15 additions & 1 deletion package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,26 @@ def viz(
target=run_server, daemon=False, kwargs={**run_server_kwargs}
)

click.echo(
click.style(
"Starting Kedro Viz ...",
fg="green",
),
)

viz_process.start()

_VIZ_PROCESSES[port] = viz_process

_wait_for(func=_check_viz_up, host=host, port=port)

print("Kedro Viz Backend Server started successfully...")
click.echo(
click.style(
"Kedro Viz started successfully. \n\n"
f"\u2728 Kedro Viz is running at \n http://{host}:{port}/",
fg="green",
)
)

if browser:
_start_browser(host, port)
Expand Down
32 changes: 25 additions & 7 deletions package/kedro_viz/server.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""`kedro_viz.server` provides utilities to launch a webserver
for Kedro pipeline visualisation."""
import multiprocessing
from pathlib import Path
from typing import Any, Dict, Optional

import uvicorn
from kedro.framework.session.store import BaseSessionStore
from kedro.io import DataCatalog
from kedro.pipeline import Pipeline
from watchgod import run_process
from watchgod import RegExpWatcher, run_process

from kedro_viz.api import apps
from kedro_viz.api.rest.responses import save_api_responses_to_fs
Expand All @@ -16,6 +17,7 @@
from kedro_viz.database import make_db_session_factory
from kedro_viz.integrations.kedro import data_loader as kedro_data_loader
from kedro_viz.integrations.kedro.sqlite_store import SQLiteStore
from kedro_viz.launchers.utils import _check_viz_up, _wait_for

DEV_PORT = 4142

Expand Down Expand Up @@ -82,8 +84,6 @@ def run_server(
take precedence over) the parameters retrieved from the project
configuration.
"""
print("Starting Kedro Viz Backend Server...")

path = Path(project_path) if project_path else Path.cwd()

if load_file is None:
Expand Down Expand Up @@ -131,12 +131,30 @@ def run_server(

project_path = (Path.cwd() / args.project_path).absolute()
bootstrap_project(project_path)
run_process(
project_path,
run_server,
kwargs={

run_process_kwargs = {
"path": project_path,
"target": run_server,
"kwargs": {
"host": args.host,
"port": args.port,
"project_path": str(project_path),
},
"watcher_cls": RegExpWatcher,
"watcher_kwargs": {"re_files": r"^.*(\.yml|\.yaml|\.py|\.json)$"},
}

viz_process = multiprocessing.Process(
target=run_process, daemon=False, kwargs={**run_process_kwargs}
)

print("Starting Kedro Viz ...")

viz_process.start()

_wait_for(func=_check_viz_up, host=args.host, port=args.port)

print(
"Kedro Viz started successfully. \n\n"
f"\u2728 Kedro Viz is running at \n http://{args.host}:{args.port}/"
)
3 changes: 2 additions & 1 deletion package/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ ipython>=7.0.0, <9.0
fastapi>=0.73.0,<0.200.0; python_version >= '3.8'
fastapi>=0.73.0,<0.104.0; python_version < '3.8'
pydantic<2
fsspec[s3]>=2021.4, <2024.1
fsspec>=2021.4, <2024.1
s3fs>=2021.4, <2024.1
aiofiles>=22.1.0
uvicorn[standard]~=0.22.0
watchgod~=0.8.2
Expand Down

0 comments on commit 8fa95a1

Please sign in to comment.