From 9f63119a83b0c0c735dabe1c65e69c94712cfb80 Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Mon, 24 Dec 2018 18:08:23 +0900 Subject: [PATCH] [rllib] Allow development without needing to compile Ray (#3623) * wip * lint * wip * wip * rename * wip * Cleaner handling of cli prompt --- doc/source/installation.rst | 4 --- doc/source/rllib-dev.rst | 5 ++++ doc/source/rllib.rst | 1 + python/ray/rllib/setup-rllib-dev.py | 38 +++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100755 python/ray/rllib/setup-rllib-dev.py diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 59cef7334..7480140d0 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -17,10 +17,6 @@ Trying snapshots from master Here are links to the latest wheels (which are built off of master). To install these wheels, run the following command: -.. danger:: - - These versions will have newer features but are subject to more bugs. If you encounter crashes or other instabilities, please revert to the latest stable version. - .. code-block:: bash pip install -U [link to wheel] diff --git a/doc/source/rllib-dev.rst b/doc/source/rllib-dev.rst index aba1589d3..688b59b7e 100644 --- a/doc/source/rllib-dev.rst +++ b/doc/source/rllib-dev.rst @@ -1,6 +1,11 @@ RLlib Development ================= +Development Install +------------------- + +You can develop RLlib locally without needing to compile Ray by using the `setup-rllib-dev.py `__ script. This sets up links between the ``rllib`` dir in your git repo and the one bundled with the ``ray`` package. When using this script, make sure that your git branch is in sync with the installed Ray binaries (i.e., you are up-to-date on `master `__ and have the latest `wheel `__ installed.) + Features -------- diff --git a/doc/source/rllib.rst b/doc/source/rllib.rst index ed7916eea..40f96b4b5 100644 --- a/doc/source/rllib.rst +++ b/doc/source/rllib.rst @@ -85,6 +85,7 @@ Models and Preprocessors RLlib Development ----------------- +* `Development Install `__ * `Features `__ * `Benchmarks `__ * `Contributing Algorithms `__ diff --git a/python/ray/rllib/setup-rllib-dev.py b/python/ray/rllib/setup-rllib-dev.py new file mode 100755 index 000000000..3876a83f7 --- /dev/null +++ b/python/ray/rllib/setup-rllib-dev.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +"""This script allows you to develop RLlib without needing to compile Ray.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import click +import os +import subprocess + +import ray + +if __name__ == "__main__": + rllib_home = os.path.abspath(os.path.join(ray.__file__, "../rllib")) + local_home = os.path.abspath(os.path.dirname(__file__)) + assert os.path.isdir(rllib_home), rllib_home + assert os.path.isdir(local_home), local_home + click.confirm( + "This will replace:\n {}\nwith a symlink to:\n {}".format( + rllib_home, local_home), + abort=True) + if os.access(os.path.dirname(rllib_home), os.W_OK): + subprocess.check_call(["rm", "-rf", rllib_home]) + subprocess.check_call(["ln", "-s", local_home, rllib_home]) + else: + print("You don't have write permission to {}, using sudo:".format( + rllib_home)) + subprocess.check_call(["sudo", "rm", "-rf", rllib_home]) + subprocess.check_call(["sudo", "ln", "-s", local_home, rllib_home]) + print("Created links.\n\nIf you run into issues initializing Ray, please " + "ensure that your local repo and the installed Ray is in sync " + "(pip install -U the latest wheels at " + "https://ray.readthedocs.io/en/latest/installation.html, " + "and ensure you are up-to-date on the master branch on git).\n\n" + "Note that you may need to delete the rllib symlink when pip " + "installing new Ray versions to prevent pip from overwriting files " + "in your git repo.")