mirror of
https://github.com/vale981/ray
synced 2025-03-05 18:11:42 -05:00
[Serve] [Doc] Serve add API ref for Deployment.bind() and serve.build (#27811)
This commit is contained in:
parent
bf9f0621b9
commit
518c74020c
5 changed files with 47 additions and 18 deletions
|
@ -27,7 +27,7 @@
|
|||
|
||||
```{eval-rst}
|
||||
.. autoclass:: ray.serve.deployment.Deployment
|
||||
:members: deploy, delete, options, get_handle
|
||||
:members: deploy, delete, options, get_handle, bind
|
||||
```
|
||||
|
||||
(servehandle-api)=
|
||||
|
@ -45,7 +45,7 @@
|
|||
.. autofunction:: ray.serve.batch(max_batch_size=10, batch_wait_timeout_s=0.0)
|
||||
```
|
||||
|
||||
## Operational APIs
|
||||
## Serve CLI and REST API
|
||||
|
||||
Check out the [CLI](serve-cli) and [REST API](serve-rest-api) for running, debugging, inspecting, and deploying Serve applications in production:
|
||||
|
||||
|
@ -55,4 +55,17 @@ Check out the [CLI](serve-cli) and [REST API](serve-rest-api) for running, debug
|
|||
|
||||
serve_cli
|
||||
rest_api
|
||||
```
|
||||
```
|
||||
|
||||
## Deployment Graph APIs
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: ray.serve.api.build
|
||||
```
|
||||
|
||||
% TODO(architkulkarni): This just compiles to "alias of Deployment(name=DAGDriver,version=None,route_prefix=/)"
|
||||
% in the docs, find out how to make Sphinx correctly autodocument this class.
|
||||
% ```{eval-rst}
|
||||
% .. autoclass:: ray.serve.drivers.DAGDriver
|
||||
% :members: predict, predict_with_route
|
||||
% ```
|
||||
|
|
|
@ -54,7 +54,7 @@ $ python3
|
|||
8
|
||||
```
|
||||
|
||||
Once we're finished, we can close the Python interpreter by running `quit()` and terminate the Ray cluster by typing `ctrl-C` int the terminal running `serve run`. This will tear down the deployments and then the cluster.
|
||||
Once we're finished, we can close the Python interpreter by running `quit()` and terminate the Ray cluster by typing `ctrl-C` into the terminal running `serve run`. This will tear down the deployments and then the cluster.
|
||||
|
||||
(serve-in-production-config-file)=
|
||||
|
||||
|
|
|
@ -16,15 +16,16 @@ class InputNode(DAGNode):
|
|||
entrypoints, but only one instance of InputNode exists per DAG, shared
|
||||
among all DAGNodes.
|
||||
|
||||
Example:
|
||||
m1.forward
|
||||
/ \
|
||||
dag_input ensemble -> dag_output
|
||||
\ /
|
||||
m2.forward
|
||||
>>> Example:
|
||||
>>> m1.forward
|
||||
>>> / \\
|
||||
>>> dag_input ensemble -> dag_output
|
||||
>>> \ /
|
||||
>>> m2.forward
|
||||
|
||||
In this pipeline, each user input is broadcasted to both m1.forward and
|
||||
m2.forward as first stop of the DAG, and authored like
|
||||
|
||||
>>> @ray.remote
|
||||
>>> class Model:
|
||||
... def __init__(self, val):
|
||||
|
|
|
@ -294,7 +294,7 @@ def deployment(
|
|||
Args:
|
||||
name (Optional[str]): Globally-unique name identifying this deployment.
|
||||
If not provided, the name of the class or function will be used.
|
||||
version (Optional[str]): Version of the deployment. This is used to
|
||||
version [DEPRECATED] (Optional[str]): Version of the deployment. This is used to
|
||||
indicate a code change for the deployment; when it is re-deployed
|
||||
with a version change, a rolling update of the replicas will be
|
||||
performed. If not provided, every deployment will be treated as a
|
||||
|
@ -330,13 +330,13 @@ def deployment(
|
|||
|
||||
Example:
|
||||
>>> from ray import serve
|
||||
>>> @serve.deployment(name="deployment1", version="v1") # doctest: +SKIP
|
||||
>>> @serve.deployment(name="deployment1") # doctest: +SKIP
|
||||
... class MyDeployment: # doctest: +SKIP
|
||||
... pass # doctest: +SKIP
|
||||
|
||||
>>> MyDeployment.deploy(*init_args) # doctest: +SKIP
|
||||
>>> MyDeployment.bind(*init_args) # doctest: +SKIP
|
||||
>>> MyDeployment.options( # doctest: +SKIP
|
||||
... num_replicas=2, init_args=init_args).deploy()
|
||||
... num_replicas=2, init_args=init_args).bind()
|
||||
|
||||
Returns:
|
||||
Deployment
|
||||
|
@ -521,13 +521,20 @@ def build(target: Union[ClassNode, FunctionNode]) -> Application:
|
|||
Serve application consisting of one or more deployments. This is intended
|
||||
to be used for production scenarios and deployed via the Serve REST API or
|
||||
CLI, so there are some restrictions placed on the deployments:
|
||||
1) All of the deployments must be importable. That is, they cannot be
|
||||
defined in __main__ or inline defined. The deployments will be
|
||||
imported in production using the same import path they were here.
|
||||
2) All arguments bound to the deployment must be JSON-serializable.
|
||||
1) All of the deployments must be importable. That is, they cannot be
|
||||
defined in __main__ or inline defined. The deployments will be
|
||||
imported in production using the same import path they were here.
|
||||
2) All arguments bound to the deployment must be JSON-serializable.
|
||||
|
||||
The returned Application object can be exported to a dictionary or YAML
|
||||
config.
|
||||
|
||||
Args:
|
||||
target (Union[ClassNode, FunctionNode]): A ClassNode or FunctionNode
|
||||
that acts as the top level node of the DAG.
|
||||
|
||||
Returns:
|
||||
The static built Serve application
|
||||
"""
|
||||
if in_interactive_shell():
|
||||
raise RuntimeError(
|
||||
|
|
|
@ -87,6 +87,7 @@ class SimpleSchemaIngress:
|
|||
@PublicAPI(stability="beta")
|
||||
@serve.deployment(route_prefix="/")
|
||||
class DAGDriver:
|
||||
"""A driver implementation that accepts HTTP requests."""
|
||||
|
||||
MATCH_ALL_ROUTE_PREFIX = "/{path:path}"
|
||||
|
||||
|
@ -95,6 +96,13 @@ class DAGDriver:
|
|||
dags: Union[RayServeDAGHandle, Dict[str, RayServeDAGHandle]],
|
||||
http_adapter: Optional[Union[str, Callable]] = None,
|
||||
):
|
||||
"""Create a DAGDriver.
|
||||
|
||||
Args:
|
||||
dags: a handle to a Ray Serve DAG or a dictionary of handles.
|
||||
http_adapter: a callable function or import string to convert
|
||||
HTTP requests to Ray Serve input.
|
||||
"""
|
||||
install_serve_encoders_to_fastapi()
|
||||
http_adapter = _load_http_adapter(http_adapter)
|
||||
self.app = FastAPI()
|
||||
|
|
Loading…
Add table
Reference in a new issue