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

Implementation of Directory Selection for Server Startup #1741

Closed
wants to merge 6 commits into from
Closed
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
10 changes: 9 additions & 1 deletion package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def viz(ctx):
type=int,
help="TCP port that viz will listen to. Defaults to 4141.",
)
@click.option(
"--project_path",
default=None,
type=str,
help="Select the indicated directory. Get the current directory if not indicated.",
)
@click.option(
"--browser/--no-browser",
default=True,
Expand Down Expand Up @@ -118,6 +124,7 @@ def viz(ctx):
def run(
host,
port,
project_path,
browser,
load_file,
save_file,
Expand Down Expand Up @@ -149,6 +156,7 @@ def run(
run_server_kwargs = {
"host": host,
"port": port,
"project_path": project_path,
"load_file": load_file,
"save_file": save_file,
"pipeline_name": pipeline,
Expand All @@ -158,7 +166,7 @@ def run(
"extra_params": params,
}
if autoreload:
project_path = Path.cwd()
project_path = Path(project_path) if project_path else Path.cwd()
run_server_kwargs["project_path"] = project_path
run_process_kwargs = {
"path": project_path,
Expand Down
14 changes: 8 additions & 6 deletions package/kedro_viz/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ def run_server(

from kedro.framework.startup import bootstrap_project

project_path_default = (Path.cwd() / args.project_path).absolute()
bootstrap_project(project_path_default)

parser = argparse.ArgumentParser(description="Launch a development viz server")
parser.add_argument("project_path", help="Path to a Kedro project")
parser.add_argument(
"--project_path", help="Path to a Kedro project", default=project_path_default
)
parser.add_argument(
"--host", help="The host of the development server", default=DEFAULT_HOST
)
Expand All @@ -139,16 +144,13 @@ def run_server(
)
args = parser.parse_args()

project_path = (Path.cwd() / args.project_path).absolute()
bootstrap_project(project_path)

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