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

Replace watchgod library with watchfiles #2134

Merged
merged 29 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
lint fix
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
jitu5 committed Oct 9, 2024
commit 9bace9ef708e7726146ca7f47ce31067b720ea6e
10 changes: 6 additions & 4 deletions package/kedro_viz/launchers/cli/run.py
Original file line number Diff line number Diff line change
@@ -12,8 +12,10 @@

_VIZ_PROCESSES: Dict[str, int] = {}


def custom_filter(_, path: str) -> bool:
return path.endswith(('.yml', '.yaml', '.py', '.json'))
return path.endswith((".yml", ".yaml", ".py", ".json"))


@viz.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.option(
@@ -175,10 +177,10 @@ def run(
"watch_filter": custom_filter,
}
viz_process = multiprocessing.Process(
target=run_process,
daemon=False,
target=run_process,
daemon=False,
args=run_process_args,
kwargs={**run_process_kwargs}
kwargs={**run_process_kwargs},
)
else:
viz_process = multiprocessing.Process(
8 changes: 5 additions & 3 deletions package/kedro_viz/launchers/jupyter.py
Original file line number Diff line number Diff line change
@@ -24,9 +24,11 @@

logger = logging.getLogger(__name__)


def custom_filter(_, file_path: str) -> bool:
return file_path.endswith((".yml", ".yaml", ".py", ".json"))


def _allocate_port(host: str, start_at: int, end_at: int = 65535) -> int:
acceptable_ports = range(start_at, end_at + 1)

@@ -157,10 +159,10 @@ def run_viz( # pylint: disable=too-many-locals
"watch_filter": custom_filter,
}
viz_process = process_context.Process(
target=run_process,
daemon=False,
target=run_process,
daemon=False,
args=run_process_args,
kwargs={**run_process_kwargs}
kwargs={**run_process_kwargs},
)
else:
viz_process = process_context.Process(
10 changes: 6 additions & 4 deletions package/kedro_viz/server.py
Original file line number Diff line number Diff line change
@@ -70,8 +70,10 @@ def load_and_populate_data(
# Creates data repositories which are used by Kedro Viz Backend APIs
populate_data(data_access_manager, catalog, pipelines, session_store, stats_dict)


def custom_filter(_, file_path: str) -> bool:
return file_path.endswith(('.yml', '.yaml', '.py', '.json'))
return file_path.endswith((".yml", ".yaml", ".py", ".json"))


# pylint: disable=too-many-positional-arguments, too-many-locals
def run_server(
@@ -170,10 +172,10 @@ def run_server(
}

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

print("Starting Kedro Viz ...")
8 changes: 4 additions & 4 deletions package/tests/test_launchers/test_cli/test_run.py
Original file line number Diff line number Diff line change
@@ -374,13 +374,13 @@ def test_kedro_viz_command_with_autoreload(
"extra_params": {},
"is_lite": False,
},
"watch_filter": custom_filter
"watch_filter": custom_filter,
}

process_init.assert_called_once_with(
target=run_process,
daemon=False,
target=run_process,
daemon=False,
args=run_process_args,
kwargs={**run_process_kwargs}
kwargs={**run_process_kwargs},
)
assert run_process_kwargs["kwargs"]["port"] in _VIZ_PROCESSES