Skip to content

Commit

Permalink
DeploymentCreator binds to Application directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
chuhan.ly committed Aug 30, 2023
1 parent 5ff89cf commit b21bb7a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions reps/2023-08-18-serve-java-dag-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class DeploymentDemo {

public static void main(String[] args) {
Application deployment =
Serve.deployment().setDeploymentDef(DeploymentDemo.class.getName()).create().bind();
RayServeHandle handle = Serve.run(deployment);
Serve.deployment().setDeploymentDef(DeploymentDemo.class.getName()).bind();
RayServeHandle handle = Serve.run(deployment).get();
System.out.println(handle.remote().get());
}
}
Expand Down Expand Up @@ -109,13 +109,11 @@ public class Driver {
}

public static void main(String[] args) {
Application modelA =
Serve.deployment().setDeploymentDef(ModelA.class.getName()).create().bind();
Application modelB =
Serve.deployment().setDeploymentDef(ModelB.class.getName()).create().bind();
Application modelA = Serve.deployment().setDeploymentDef(ModelA.class.getName()).bind();
Application modelB = Serve.deployment().setDeploymentDef(ModelB.class.getName()).bind();

Application driver =
Serve.deployment().setDeploymentDef(Driver.class.getName()).create().bind(modelA, modelB);
Serve.deployment().setDeploymentDef(Driver.class.getName()).bind(modelA, modelB);
Serve.run(driver);
}
}
Expand Down Expand Up @@ -155,13 +153,11 @@ public class Model {
Application model =
Serve.deployment()
.setDeploymentDef(Model.class.getName())
.create()
.bind(2);
Application pyPreprocess =
Serve.deployment()
.setDeploymentDef("deployment_graph.preprocess")
.setLanguage(DeploymentLanguage.PYTHON)
.create()
.bind(inp);
Application output = model.method("predict").bind(pyPreprocess);
Application serveDag = DAGDriver.bind(output);
Expand All @@ -184,8 +180,10 @@ One more thing to note is the usage of `InputNode`. In Python, `InputNode` is ve
// Demo 4
import io.ray.serve.api.Serve;
import io.ray.serve.deployment.Application;
import io.ray.serve.deployment.DAGDriver;
import io.ray.serve.deployment.InputNode;
import io.ray.serve.generated.DeploymentLanguage;
import io.ray.serve.handle.RayServeHandle;

public class Model {

Expand All @@ -202,8 +200,8 @@ public class Model {
}

public static void main(String[] args) throws Exception {
Application m1 = Serve.deployment().setDeploymentDef(Model.class.getName()).create().bind(1);
Application m2 = Serve.deployment().setDeploymentDef(Model.class.getName()).create().bind(2);
Application m1 = Serve.deployment().setDeploymentDef(Model.class.getName()).bind(1);
Application m2 = Serve.deployment().setDeploymentDef(Model.class.getName()).bind(2);

try (InputNode userInput = InputNode.create()) {
Application m1Output = m1.method("forward").bind(userInput.get(0));
Expand All @@ -212,9 +210,8 @@ public class Model {
Serve.deployment()
.setDeploymentDef("deployment_graph.combine")
.setLanguage(DeploymentLanguage.PYTHON)
.create()
.bind(m1Output, m2Output, userInput.get(2));

Application graph = DAGDriver.bind(combineOutput);
RayServeHandle handle = Serve.run(graph);
}
Expand Down

0 comments on commit b21bb7a

Please sign in to comment.