-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Kedro Viz Connection Error (#1507)
* initial draft for resolving connection error * refactor launchers and test code * modify unit tests * fix lint errors * fix run_viz tests * update unit test for coverage * update unit tests * Refactor visualize dataset stats from DataNodeMetadata to DataNode (#1499) * add stats to data node * lint and format check fix * fix pytests * fix layout issue * fix transcoded data stats Signed-off-by: ravi-kumar-pilla <[email protected]> * initial draft for resolving connection error Signed-off-by: ravi-kumar-pilla <[email protected]> * Support for Python 3.11 (#1502) * initial draft for python 3.11 support * update release doc * add python warnings for e2e tests * modify e2e test * modify e2e test * test by removing lower req scenario * skip e2e tests for lower bound requirement on python 3.11 * skip e2e tests for lower bound requirement on python 3.11 * remove print statements --------- Co-authored-by: Nok Lam Chan <[email protected]> Signed-off-by: ravi-kumar-pilla <[email protected]> * Remove Python Upper Bound Requirements (#1506) * initial draft for python 3.11 support * update release doc * add python warnings for e2e tests * modify e2e test * modify e2e test * test by removing lower req scenario * skip e2e tests for lower bound requirement on python 3.11 * skip e2e tests for lower bound requirement on python 3.11 * remove python upperbounds initial draft * fix lint and format errors * test remove upperbound warning * test lowerbound pandas install * revert back pandas requirement * bump lower requirements for pandas * remove upper bound clean up * update release notes * fix PR comments --------- Co-authored-by: Nok Lam Chan <[email protected]> Signed-off-by: ravi-kumar-pilla <[email protected]> * refactor launchers and test code Signed-off-by: ravi-kumar-pilla <[email protected]> * modify unit tests Signed-off-by: ravi-kumar-pilla <[email protected]> * fix lint errors Signed-off-by: ravi-kumar-pilla <[email protected]> * Fix: Adding favicon to Kedro Demo (#1509) * Fix: Adding favicon to Kedro Demo * Fix: Change in approach for serving favicon * Lint error fix * Lint error fix * Favicon endpoint test added * Favicon endpoint test added * Lint error fixed * Fix: Adding favicon to Kedro Demo Signed-off-by: Jitendra Gundaniya <[email protected]> * Fix: Change in approach for serving favicon Signed-off-by: Jitendra Gundaniya <[email protected]> * Lint error fix Signed-off-by: Jitendra Gundaniya <[email protected]> * Lint error fix Signed-off-by: Jitendra Gundaniya <[email protected]> * Favicon endpoint test added Signed-off-by: Jitendra Gundaniya <[email protected]> * Favicon endpoint test added Signed-off-by: Jitendra Gundaniya <[email protected]> * Lint error fixed Signed-off-by: Jitendra Gundaniya <[email protected]> * Fixed favicon endpoint test * Release doc updated * Update RELEASE.md Co-authored-by: rashidakanchwala <[email protected]> * Removed pytest.fixture as per review comment --------- Signed-off-by: Jitendra Gundaniya <[email protected]> Co-authored-by: rashidakanchwala <[email protected]> Signed-off-by: ravi-kumar-pilla <[email protected]> * fix run_viz tests Signed-off-by: ravi-kumar-pilla <[email protected]> * update unit test for coverage Signed-off-by: ravi-kumar-pilla <[email protected]> * Release v6.5.0 (#1513) * v6.5.0 * release * update-reminder-content * update reminder Signed-off-by: ravi-kumar-pilla <[email protected]> * remove branch condition for automate release version check (#1514) Signed-off-by: ravi-kumar-pilla <[email protected]> * update unit tests Signed-off-by: ravi-kumar-pilla <[email protected]> * add release record * modify comment * fix PR comments * DCO fix * fixing dco Signed-off-by: ravi-kumar-pilla <[email protected]> * update pytest Signed-off-by: ravi-kumar-pilla <[email protected]> --------- Signed-off-by: ravi-kumar-pilla <[email protected]> Signed-off-by: Jitendra Gundaniya <[email protected]> Co-authored-by: Rashida Kanchwala <[email protected]> Co-authored-by: Nok Lam Chan <[email protected]> Co-authored-by: Jitendra Gundaniya <[email protected]> Co-authored-by: rashidakanchwala <[email protected]>
- Loading branch information
1 parent
da47408
commit 335be7d
Showing
9 changed files
with
241 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
"""`kedro_viz.launchers.utils` contains utility functions | ||
used in the `kedro_viz.launchers` package.""" | ||
import logging | ||
import webbrowser | ||
from time import sleep, time | ||
from typing import Any, Callable | ||
|
||
import requests | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class WaitForException(Exception): | ||
"""WaitForException: if func doesn't return expected result within the specified time""" | ||
|
||
|
||
def _wait_for( | ||
func: Callable, | ||
expected_result: Any = True, | ||
timeout: int = 60, | ||
print_error: bool = True, | ||
sleep_for: int = 1, | ||
**kwargs, | ||
) -> None: | ||
""" | ||
Run specified function until it returns expected result until timeout. | ||
Args: | ||
func (Callable): Specified function to call | ||
expected_result (Any): result that is expected. Defaults to None. | ||
timeout (int): Time out in seconds. Defaults to 10. | ||
print_error (boolean): whether any exceptions raised should be printed. | ||
Defaults to False. | ||
sleep_for (int): Execute func every specified number of seconds. | ||
Defaults to 1. | ||
**kwargs: Arguments to be passed to func | ||
Raises: | ||
WaitForException: if func doesn't return expected result within the | ||
specified time | ||
""" | ||
end = time() + timeout | ||
|
||
while time() <= end: | ||
try: | ||
retval = func(**kwargs) | ||
except Exception as err: # pylint: disable=broad-except | ||
if print_error: | ||
logger.error(err) | ||
else: | ||
if retval == expected_result: | ||
return None | ||
sleep(sleep_for) | ||
|
||
raise WaitForException( | ||
f"func: {func}, didn't return {expected_result} within specified timeout: {timeout}" | ||
) | ||
|
||
|
||
def _check_viz_up(host: str, port: int): | ||
"""Checks if Kedro Viz Server has started and is responding to requests | ||
Args: | ||
host: the host that launched the webserver | ||
port: the port the webserver is listening | ||
""" | ||
|
||
url = f"http://{host}:{port}" | ||
try: | ||
response = requests.get(url, timeout=10) | ||
except requests.ConnectionError: | ||
return False | ||
|
||
return response.status_code == 200 | ||
|
||
|
||
def _is_localhost(host: str) -> bool: | ||
"""Check whether a host is a localhost""" | ||
return host in ("127.0.0.1", "localhost", "0.0.0.0") | ||
|
||
|
||
def _start_browser(host: str, port: int): | ||
"""Starts a new browser window only on a local interface | ||
Args: | ||
host: browser url host | ||
port: browser url port | ||
""" | ||
|
||
if _is_localhost(host): | ||
webbrowser.open_new(f"http://{host}:{port}/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.