Skip to content

Commit ad08be4

Browse files
author
chuhan.ly
committed
DeploymentCreator binds to Application directly.
Signed-off-by: chuhan.ly <[email protected]>
1 parent 35af175 commit ad08be4

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

reps/2023-08-18-serve-java-dag-api.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public class DeploymentDemo {
6565

6666
public static void main(String[] args) {
6767
Application deployment =
68-
Serve.deployment().setDeploymentDef(DeploymentDemo.class.getName()).create().bind();
69-
RayServeHandle handle = Serve.run(deployment);
68+
Serve.deployment().setDeploymentDef(DeploymentDemo.class.getName()).bind();
69+
RayServeHandle handle = Serve.run(deployment).get();
7070
System.out.println(handle.remote().get());
7171
}
7272
}
@@ -109,13 +109,11 @@ public class Driver {
109109
}
110110

111111
public static void main(String[] args) {
112-
Application modelA =
113-
Serve.deployment().setDeploymentDef(ModelA.class.getName()).create().bind();
114-
Application modelB =
115-
Serve.deployment().setDeploymentDef(ModelB.class.getName()).create().bind();
112+
Application modelA = Serve.deployment().setDeploymentDef(ModelA.class.getName()).bind();
113+
Application modelB = Serve.deployment().setDeploymentDef(ModelB.class.getName()).bind();
116114

117115
Application driver =
118-
Serve.deployment().setDeploymentDef(Driver.class.getName()).create().bind(modelA, modelB);
116+
Serve.deployment().setDeploymentDef(Driver.class.getName()).bind(modelA, modelB);
119117
Serve.run(driver);
120118
}
121119
}
@@ -155,13 +153,11 @@ public class Model {
155153
Application model =
156154
Serve.deployment()
157155
.setDeploymentDef(Model.class.getName())
158-
.create()
159156
.bind(2);
160157
Application pyPreprocess =
161158
Serve.deployment()
162159
.setDeploymentDef("deployment_graph.preprocess")
163160
.setLanguage(DeploymentLanguage.PYTHON)
164-
.create()
165161
.bind(inp);
166162
Application output = model.method("predict").bind(pyPreprocess);
167163
Application serveDag = DAGDriver.bind(output);
@@ -184,8 +180,10 @@ One more thing to note is the usage of `InputNode`. In Python, `InputNode` is ve
184180
// Demo 4
185181
import io.ray.serve.api.Serve;
186182
import io.ray.serve.deployment.Application;
183+
import io.ray.serve.deployment.DAGDriver;
187184
import io.ray.serve.deployment.InputNode;
188185
import io.ray.serve.generated.DeploymentLanguage;
186+
import io.ray.serve.handle.RayServeHandle;
189187

190188
public class Model {
191189

@@ -202,8 +200,8 @@ public class Model {
202200
}
203201

204202
public static void main(String[] args) throws Exception {
205-
Application m1 = Serve.deployment().setDeploymentDef(Model.class.getName()).create().bind(1);
206-
Application m2 = Serve.deployment().setDeploymentDef(Model.class.getName()).create().bind(2);
203+
Application m1 = Serve.deployment().setDeploymentDef(Model.class.getName()).bind(1);
204+
Application m2 = Serve.deployment().setDeploymentDef(Model.class.getName()).bind(2);
207205

208206
try (InputNode userInput = InputNode.create()) {
209207
Application m1Output = m1.method("forward").bind(userInput.get(0));
@@ -212,9 +210,8 @@ public class Model {
212210
Serve.deployment()
213211
.setDeploymentDef("deployment_graph.combine")
214212
.setLanguage(DeploymentLanguage.PYTHON)
215-
.create()
216213
.bind(m1Output, m2Output, userInput.get(2));
217-
214+
218215
Application graph = DAGDriver.bind(combineOutput);
219216
RayServeHandle handle = Serve.run(graph);
220217
}

0 commit comments

Comments
 (0)