You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Delete DAGDriver and InputNode. 2. Add DeploymentHandle and DeploymentResponse demo. 3. Adjusting the way Python deploys deployment for other languages.
@@ -37,14 +34,14 @@ Main `ray` project. A part of java/serve.
37
34
## Stewardship
38
35
39
36
### Required Reviewers
40
-
@sihanwang41
37
+
@sihanwang41@edoakes
41
38
42
39
### Shepherd of the Proposal (should be a senior committer)
43
-
@sihanwang41
40
+
@sihanwang41@edoakes
44
41
45
42
## Design and Architecture
46
43
47
-
### Update Java user API to be consistent with Python
44
+
### Update Java User API to be Consistent with Python
48
45
A standard Java deployment demo is shown below:
49
46
```java
50
47
// Demo 1
@@ -73,27 +70,27 @@ public class DeploymentDemo {
73
70
74
71
```
75
72
In this demo, a DAG node is defined through the `bind` method of the Deployment, and it is deployed using the `Serve.run` API.
76
-
Furthermore, a Deployment can bind other Deployments, and users can use the Deployment input parameters in a similar way to `RayServeHandle`. For example:
73
+
Furthermore, a Deployment can bind other Deployments, and users can use the Deployment input parameters in a similar way to `DeploymentHandle`. For example:
In this example, modelA and modelB are defined as two Deployments, and driver is instantiated with the corresponding `RayServeHandle` of these two Deployments. When `call` is executed, both models are invoked. Additionally, more complex graphs can be composed, for example:
* model: a Java Deployment where the `predict` method takes an integer input and performs addition with the initialized value.
174
-
* pyPreprocess: a Python deployment that adds one to the input parameter.
175
-
176
-
During the graph composition, the output of pyPreprocess will be used as input to the `model.predict` method. `DAGDriver` acts as the Ingress Deployment and orchestrates the entire graph. Finally, the graph is deployed using `Serve.run`.
177
-
178
-
One more thing to note is the usage of `InputNode`. In Python, `InputNode` is very flexible and can represent a list, a dict, or structured object. However, in Java, it is difficult to simulate the invocation of arbitrary objects using `InputNode`, so we have made some compromises. We can simulate the invocation of a List or a Map using the `InputNode.get` method. As for structured objects, the only option is to pass the entire `InputNode` as a parameter. Here's an example:
179
-
```java
180
-
// Demo 4
181
-
importio.ray.serve.api.Serve;
182
-
importio.ray.serve.deployment.Application;
183
-
importio.ray.serve.deployment.DAGDriver;
184
-
importio.ray.serve.deployment.InputNode;
185
-
importio.ray.serve.generated.DeploymentLanguage;
186
-
importio.ray.serve.handle.RayServeHandle;
187
-
188
-
publicclassModel {
189
-
190
-
privateint weight;
191
-
192
-
publicModel() {}
193
-
194
-
publicModel(intweight) {
195
-
this.weight = weight;
196
-
}
119
+
In this example, the modelA and modelB are defined as two Deployments, and the driver is instantiated with the corresponding `DeploymentHandle` of these two Deployments. When `call` is executed, both models are invoked. Additionally, it is evident that `DeploymentHandle.remote` returns `DeploymentResponse` instead of `ObjectRef`. The result can be accessed through `DeploymentResponse.result`.
### Deploying Deployments of the Other Languages through Python API
122
+
In another REP ([Add Cpp Deployment in Ray Serve](https://github.com/ray-project/enhancements/pull/34)), it is mentioned how to deploy C++ deployments through Python. Deploying Java deployments through Python is similar. Since Java and C++ do not have the decorator mechanism like Python, a straightforward way is to directly use the `serve.deployment` API (with the addition of a new `language` parameter):
In the above examples, both Demo 1 and Demo 2 are deployments of regular Java applications, which are relatively easy to implement. However, for Demo 3 and Demo 4, they involve Python `DAGDriver`, where the input of `DAGDriver` may contain `RayServeDAGHandle` that carries information for graph execution. In order to fully support graph execution orchestration through Python `DAGDriver`, it would require support for cross-language transmission of several internal core types, such as `RayServeDAGHandle`, `DeploymentMethodExecutorNode`, `DeploymentFunctionExecutorNode`, `InputAttributeNode`, and `InputNode`. This could be a significant change and needs further evaluation.
224
-
225
-
### Deploying deployments of other languages through Python API
226
-
In another REP ([Add Cpp Deployment in Ray Serve](https://github.com/ray-project/enhancements/pull/34)), it is mentioned how to deploy C++ deployments through Python. Deploying Java deployments through Python is similar. Since Java and C++ do not have the decorator mechanism like Python, a straightforward way is to directly instantiate the corresponding Deployment object:
128
+
### Deploying through the Config File
129
+
// TODO
227
130
228
-
```python
229
-
deployment_config = DeploymentConfig()
230
-
deployment_config.deployment_language =JAVA# or CPP
In the design of C++ Deployment, it also includes the C++ implementation of Serve Handle. After the implementation, it can be reused as the core of Serve Handle by other languages (Python and Java) to avoid maintaining duplicate logic in the three languages. For the complete design, we will continue to supplement it in the "[Cpp Deployment Design](https://github.com/ray-project/enhancements/pull/34)" or another new document.
237
134
238
-
```
239
135
## Compatibility, Deprecation, and Migration Plan
240
136
In Java, the old API will be marked with the @Deprecated annotation, for example:
241
137
```java
@@ -263,4 +159,4 @@ Related test cases will be provided under ray/java/serve, and they will cover th
263
159
## (Optional) Follow-on Work
264
160
- Modify the Ray Serve Java API to support the usage of DAGs.
265
161
- Optimize the code by removing unused components and improving cross-language parameter handling.
0 commit comments