Skip to content

Commit

Permalink
feature: add project_path argument
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Santana <[email protected]>
  • Loading branch information
santana98 committed Feb 19, 2024
1 parent 5604c9d commit 6733614
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 9 additions & 1 deletion package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 @@ -113,6 +119,7 @@ def viz(ctx):
def run(
host,
port,
project_path,
browser,
load_file,
save_file,
Expand Down Expand Up @@ -147,6 +154,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 @@ -156,7 +164,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 @@ -127,8 +127,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 @@ -137,16 +142,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

0 comments on commit 6733614

Please sign in to comment.