Search…
Server
Simple example to deploy a server with Konduit-Serving
In this example, we'll deploy a server with Konduit-Serving.
  • First, let's start with creating a complete configuration of the server.
1
InferenceConfiguration inferenceConfiguration = new InferenceConfiguration();
2
inferenceConfiguration.pipeline(
3
SequencePipeline
4
.builder()
5
.add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES))
6
.build()
7
);
Copied!
  • Let's deploy the server with the configuration made above. The successful server deployment will give the port number and host of the server:
1
DeployKonduitServing.deploy(
2
new VertxOptions(), // Default vertx options
3
new DeploymentOptions(), // Default deployment options
4
inferenceConfiguration, // Inference configuration with logging step
5
handler -> { // this block will be called when server finishes the deployment
6
if (handler.succeeded()) { // If the server is sucessfully running
7
// Getting the result of the deployment
8
InferenceDeploymentResult inferenceDeploymentResult = handler.result();
9
int runnningPort = inferenceDeploymentResult.getActualPort();
10
String deploymentId = inferenceDeploymentResult.getDeploymentId();
11
12
System.out.format("The server is running on port %s with deployment id of %s%n",
13
runnningPort, deploymentId);
14
15
try {
16
String result = Unirest.post(String.format("http://localhost:%s/predict", runnningPort))
17
.header("Content-Type", "application/json")
18
.header("Accept", "application/json")
19
.body(new JSONObject().put("input_key", "input_value"))
20
.asString().getBody();
21
22
System.out.format("Result from server : %s%n", result);
23
24
System.exit(0);
25
} catch (UnirestException e) {
26
e.printStackTrace();
27
28
System.exit(1);
29
}
30
} else { // If the server failed to run
31
System.out.println(handler.cause().getMessage());
32
System.exit(1);
33
}
34
});
Copied!
You'll be able to see the output similar to this once the server successfully deployed:
1
The server is running on port 37663 with deployment id of 59d5d475-be83-4348-8983-4d3e7328e71d
2
Result from server : {
3
"input_key" : "input_value"
4
}
5
6
Process finished with exit code 0
Copied!
Copy link