client.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Tune Client API
  2. ===============
  3. You can interact with an ongoing experiment with the Tune Client API. The Tune Client API is organized around REST, which includes resource-oriented URLs, accepts form-encoded requests, returns JSON-encoded responses, and uses standard HTTP protocol.
  4. To allow Tune to receive and respond to your API calls, you have to start your experiment with ``tune.run(server_port)``:
  5. .. code-block:: python
  6. tune.run(..., server_port=4321)
  7. The easiest way to use the Tune Client API is with the built-in TuneClient. To use TuneClient, verify that you have the ``requests`` library installed:
  8. .. code-block:: bash
  9. $ pip install requests
  10. Then, on the client side, you can use the following class. If on a cluster, you may want to forward this port (e.g. ``ssh -L <local_port>:localhost:<remote_port> <address>``) so that you can use the Client on your local machine.
  11. .. autoclass:: ray.tune.web_server.TuneClient
  12. :members:
  13. For an example notebook for using the Client API, see the `Client API Example <https://github.com/ray-project/ray/tree/master/python/ray/tune/TuneClient.ipynb>`__.
  14. The API also supports curl. Here are the examples for getting trials (``GET /trials/[:id]``):
  15. .. code-block:: bash
  16. $ curl http://<address>:<port>/trials
  17. $ curl http://<address>:<port>/trials/<trial_id>
  18. And stopping a trial (``PUT /trials/:id``):
  19. .. code-block:: bash
  20. $ curl -X PUT http://<address>:<port>/trials/<trial_id>