2022-07-09 02:58:21 +08:00
(serve-api)=
2022-05-10 14:04:17 -07:00
# Ray Serve API
2020-06-15 18:47:59 -07:00
2022-08-03 12:30:33 -07:00
(core-apis)=
2022-05-10 14:04:17 -07:00
## Core APIs
```{eval-rst}
2020-09-04 12:02:23 -05:00
.. autofunction:: ray.serve.start
2022-05-10 14:04:17 -07:00
```
```{eval-rst}
2021-05-03 13:19:34 -05:00
.. autofunction:: ray.serve.deployment
2022-05-10 14:04:17 -07:00
```
```{eval-rst}
2021-05-03 13:19:34 -05:00
.. autofunction:: ray.serve.list_deployments
2022-05-10 14:04:17 -07:00
```
```{eval-rst}
2021-05-03 13:19:34 -05:00
.. autofunction:: ray.serve.get_deployment
2022-05-10 14:04:17 -07:00
```
```{eval-rst}
2021-05-03 13:19:34 -05:00
.. autofunction:: ray.serve.shutdown
2022-05-10 14:04:17 -07:00
```
2020-06-15 18:47:59 -07:00
2022-05-10 14:04:17 -07:00
(deployment-api)=
2021-05-03 13:19:34 -05:00
2022-05-10 14:04:17 -07:00
## Deployment API
2021-05-03 13:19:34 -05:00
2022-05-10 14:04:17 -07:00
```{eval-rst}
2022-04-01 13:40:13 -07:00
.. autoclass:: ray.serve.deployment.Deployment
2021-05-03 13:19:34 -05:00
:members: deploy, delete, options, get_handle
2022-05-10 14:04:17 -07:00
```
(servehandle-api)=
2020-06-15 18:47:59 -07:00
2022-05-10 14:04:17 -07:00
## ServeHandle API
2020-12-28 10:19:36 -08:00
2022-05-10 14:04:17 -07:00
```{eval-rst}
2020-06-15 18:47:59 -07:00
.. autoclass:: ray.serve.handle.RayServeHandle
2020-09-04 12:02:23 -05:00
:members: remote, options
2022-05-10 14:04:17 -07:00
```
## Batching Requests
2020-06-15 18:47:59 -07:00
2022-05-10 14:04:17 -07:00
```{eval-rst}
2021-05-11 03:23:58 -05:00
.. autofunction:: ray.serve.batch(max_batch_size=10, batch_wait_timeout_s=0.0)
2022-05-10 14:04:17 -07:00
```
2022-06-24 14:06:26 -07:00
2022-08-03 12:30:33 -07:00
(serve-rest-api)=
2022-06-24 14:06:26 -07:00
## Serve REST API
### REST API
#### `GET "/api/serve/deployments/"`
Gets latest config that Serve has received. This config represents the current goal state for the Serve application. Starts a Serve application on the Ray cluster if it's not already running. See the [config schema ](serve-rest-api-config-schema ) for the response's JSON schema.
**Example Request**:
```
GET /api/serve/deployments/ HTTP 1.1
2022-08-04 10:24:57 -07:00
Host: http://localhost:52365/
2022-06-24 14:06:26 -07:00
Accept: application/json
```
**Example Response**:
```http
HTTP/1.1 200 OK
Content-Type: application/json
{
"import_path": "fruit.deployment_graph",
"runtime_env": {
"working_dir": "https://github.com/ray-project/serve_config_examples/archive/HEAD.zip"
},
"deployments": [
{"name": "MangoStand", "user_config": {"price": 1}},
{"name": "OrangeStand", "user_config": {"price": 2}},
{"name": "PearStand", "user_config": {"price": 3}}
]
}
```
#### `PUT "/api/serve/deployments/"`
Declaratively deploys the Serve application. Starts Serve on the Ray cluster if it's not already running. See the [config schema ](serve-rest-api-config-schema ) for the request's JSON schema.
**Example Request**:
```
PUT /api/serve/deployments/ HTTP 1.1
2022-08-04 10:24:57 -07:00
Host: http://localhost:52365/
2022-06-24 14:06:26 -07:00
Accept: application/json
{
"import_path": "fruit.deployment_graph",
"runtime_env": {
"working_dir": "https://github.com/ray-project/serve_config_examples/archive/HEAD.zip"
},
"deployments": [
{"name": "MangoStand", "user_config": {"price": 1}},
{"name": "OrangeStand", "user_config": {"price": 2}},
{"name": "PearStand", "user_config": {"price": 3}}
]
}
```
**Example Response**
```http
HTTP/1.1 200 OK
Content-Type: application/json
```
#### `GET "/api/serve/deployments/status"`
Gets the Serve application's current status, including all the deployment statuses. This config represents the current goal state for the Serve application. Starts a Serve application on the Ray cluster if it's not already running. See the [status schema ](serve-rest-api-status-schema ) for the response's JSON schema.
**Example Request**:
```
GET /api/serve/deployments/ HTTP 1.1
2022-08-04 10:24:57 -07:00
Host: http://localhost:52365/
2022-06-24 14:06:26 -07:00
Accept: application/json
```
**Example Response**
```http
HTTP/1.1 200 OK
Content-Type: application/json
{
"app_status": {
"status": "RUNNING",
"message": "",
"deployment_timestamp": 1855994527.146304
},
"deployment_statuses": [
{
"name": "MangoStand",
"status": "HEALTHY",
"message": ""
},
{
"name": "OrangeStand",
"status": "HEALTHY",
"message": ""
},
{
"name": "PearStand",
"status": "HEALTHY",
"message": ""
},
{
"name": "FruitMarket",
"status": "HEALTHY",
"message": ""
},
{
"name": "DAGDriver",
"status": "HEALTHY",
"message": ""
}
]
}
```
#### `DELETE "/api/serve/deployments/"`
Shuts down the Serve application running on the Ray cluster. Has no
effect if Serve is not running on the Ray cluster.
**Example Request**:
```
DELETE /api/serve/deployments/ HTTP 1.1
2022-08-04 10:24:57 -07:00
Host: http://localhost:52365/
2022-06-24 14:06:26 -07:00
Accept: application/json
```
**Example Response**
```http
HTTP/1.1 200 OK
Content-Type: application/json
```
(serve-rest-api-config-schema)=
### Config Schema
```{eval-rst}
.. autopydantic_model:: ray.serve.schema.ServeApplicationSchema
```
(serve-rest-api-status-schema)=
### Status Schema
```{eval-rst}
.. autopydantic_model:: ray.serve.schema.ServeStatusSchema
```
2022-08-03 12:30:33 -07:00
(serve-cli)=
2022-06-24 14:06:26 -07:00
## Serve CLI
```{eval-rst}
.. click:: ray.serve.scripts:cli
:prog: serve
:show-nested:
```