From 9ce30393903555fcc8a33346b1584f964594b67d Mon Sep 17 00:00:00 2001 From: Si-Yuan Date: Sat, 27 Apr 2019 15:23:56 +0800 Subject: [PATCH] Fix webui api (#4686) * fix webui * Apply suggestions from code review lint Co-Authored-By: suquark * add dependencies for this unittest * move dependencies to the script file --- ci/travis/install-dependencies.sh | 4 ++-- python/ray/tests/test_webui.py | 17 +++++++++++++++++ python/ray/worker.py | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 python/ray/tests/test_webui.py diff --git a/ci/travis/install-dependencies.sh b/ci/travis/install-dependencies.sh index 0af623627..4acf98501 100755 --- a/ci/travis/install-dependencies.sh +++ b/ci/travis/install-dependencies.sh @@ -34,7 +34,7 @@ elif [[ "$PYTHON" == "3.5" ]] && [[ "$platform" == "linux" ]]; then bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" pip install -q scipy tensorflow cython==0.29.0 gym opencv-python-headless pyyaml pandas==0.23.4 requests \ - feather-format lxml openpyxl xlrd py-spy setproctitle pytest-timeout flaky networkx tabulate psutil + feather-format lxml openpyxl xlrd py-spy setproctitle pytest-timeout flaky networkx tabulate psutil aiohttp elif [[ "$PYTHON" == "2.7" ]] && [[ "$platform" == "macosx" ]]; then # Install miniconda. wget https://repo.continuum.io/miniconda/Miniconda2-4.5.4-MacOSX-x86_64.sh -O miniconda.sh -nv @@ -48,7 +48,7 @@ elif [[ "$PYTHON" == "3.5" ]] && [[ "$platform" == "macosx" ]]; then bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" pip install -q cython==0.29.0 tensorflow gym opencv-python-headless pyyaml pandas==0.23.4 requests \ - feather-format lxml openpyxl xlrd py-spy setproctitle pytest-timeout flaky networkx tabulate psutil + feather-format lxml openpyxl xlrd py-spy setproctitle pytest-timeout flaky networkx tabulate psutil aiohttp elif [[ "$LINT" == "1" ]]; then sudo apt-get update sudo apt-get install -y build-essential curl unzip diff --git a/python/ray/tests/test_webui.py b/python/ray/tests/test_webui.py new file mode 100644 index 000000000..3e277ed85 --- /dev/null +++ b/python/ray/tests/test_webui.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import sys +import pytest +import ray + + +@pytest.mark.skipif( + sys.version_info < (3, 5, 3), reason="requires python3.5.3 or higher") +def test_get_webui(): + addresses = ray.init(include_webui=True) + webui_url = addresses["webui_url"] + assert ray.worker.get_webui_url() == webui_url + + ray.shutdown() diff --git a/python/ray/worker.py b/python/ray/worker.py index f8c66c72a..5c4d416b9 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -1102,7 +1102,7 @@ def get_webui_url(): """ if _global_node is None: raise Exception("Ray has not been initialized/connected.") - return _global_node.get_webui_url + return _global_node.webui_url global_worker = Worker()