Skip to content

Commit

Permalink
[tune] Fix Docs (ray-project#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardliaw authored Jan 26, 2018
1 parent e96acc2 commit f3d2dc0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .travis/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ if [[ "$PYTHON" == "2.7" ]] && [[ "$platform" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh -nv
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas requests
elif [[ "$PYTHON" == "3.5" ]] && [[ "$platform" == "linux" ]]; then
sudo apt-get update
sudo apt-get install -y cmake pkg-config python-dev python-numpy build-essential autoconf curl libtool unzip
# Install miniconda.
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -nv
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas requests
elif [[ "$PYTHON" == "2.7" ]] && [[ "$platform" == "macosx" ]]; then
# check that brew is installed
which -s brew
Expand All @@ -48,7 +48,7 @@ elif [[ "$PYTHON" == "2.7" ]] && [[ "$platform" == "macosx" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh -O miniconda.sh -nv
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas requests
elif [[ "$PYTHON" == "3.5" ]] && [[ "$platform" == "macosx" ]]; then
# check that brew is installed
which -s brew
Expand All @@ -64,7 +64,7 @@ elif [[ "$PYTHON" == "3.5" ]] && [[ "$platform" == "macosx" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh -nv
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas
pip install -q numpy cython cmake funcsigs click colorama psutil redis tensorflow gym flatbuffers opencv-python pyyaml pandas requests
elif [[ "$LINT" == "1" ]]; then
sudo apt-get update
sudo apt-get install -y cmake build-essential autoconf curl libtool unzip
Expand Down
Binary file added doc/source/ray-tune-parcoords.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions doc/source/tune.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,16 @@ Visualizing Results

Ray Tune logs trial results to a unique directory per experiment, e.g. ``~/ray_results/my_experiment`` in the above example. The log records are compatible with a number of visualization tools:

To visualize learning in tensorboard, run:
To visualize learning in tensorboard, install TensorFlow:

.. code-block:: bash
$ pip install tensorflow
Then, after you run a experiment, you can visualize your experiment with TensorBoard by specifying the output directory of your results:

.. code-block:: bash
$ pip install tensorboard
$ tensorboard --logdir=~/ray_results/my_experiment
.. image:: ray-tune-tensorboard.png
Expand All @@ -92,6 +97,8 @@ Finally, to view the results with a `parallel coordinates visualization <https:/
$ cd $RAY_HOME/python/ray/tune
$ jupyter-notebook ParallelCoordinatesVisualization.ipynb
.. image:: ray-tune-parcoords.png

Trial Variant Generation
------------------------

Expand Down Expand Up @@ -182,7 +189,13 @@ If your trainable function / class creates further Ray actors or tasks that also
Client API
----------

You can modify an ongoing experiment by adding or deleting trials using the Tune Client API. To do this, start your experiment with ``with_server=True``:
You can modify an ongoing experiment by adding or deleting trials using the Tune Client API. To do this, verify that you have the ``requests`` library installed:

.. code-block:: bash
$ pip install requests
To use the Client API, you can start your experiment with ``with_server=True``:

.. code-block:: python
Expand Down
10 changes: 9 additions & 1 deletion python/ray/tune/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import os
import sys
import tensorflow as tf

from ray.tune.result import TrainingResult

Expand All @@ -16,6 +15,12 @@
elif sys.version_info[0] == 3:
import io as StringIO

try:
import tensorflow as tf
except ImportError:
tf = None
print("Couldn't import TensorFlow - this disables TensorBoard logging.")


class Logger(object):
"""Logging interface for ray.tune; specialized implementations follow.
Expand Down Expand Up @@ -54,6 +59,9 @@ class UnifiedLogger(Logger):
def _init(self):
self._loggers = []
for cls in [_JsonLogger, _TFLogger, _VisKitLogger]:
if cls is _TFLogger and tf is None:
print("TF not installed - cannot log with {}...".format(cls))
continue
self._loggers.append(cls(self.config, self.logdir, self.uri))
print("Unified logger created with logdir '{}'".format(self.logdir))

Expand Down
18 changes: 15 additions & 3 deletions python/ray/tune/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
from __future__ import division
from __future__ import print_function

import requests
import json
import sys
import threading
from http.server import HTTPServer, BaseHTTPRequestHandler

from ray.tune.error import TuneError, TuneManagerError
from ray.tune.variant_generator import generate_trials

if sys.version_info[0] == 2:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer as HTTPServer
elif sys.version_info[0] == 3:
from http.server import SimpleHTTPRequestHandler, HTTPServer

try:
import requests # `requests` is not part of stdlib.
except ImportError:
requests = None
print("Couldn't import `requests` library. Be sure to install it on"
" the client side.")


class TuneClient(object):
"""Client to interact with ongoing Tune experiment.
Expand Down Expand Up @@ -58,7 +70,7 @@ def _get_response(self, data):


def RunnerHandler(runner):
class Handler(BaseHTTPRequestHandler):
class Handler(SimpleHTTPRequestHandler):

def do_GET(self):
content_len = int(self.headers.get('Content-Length'), 0)
Expand Down

0 comments on commit f3d2dc0

Please sign in to comment.