-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.go
59 lines (48 loc) · 1.73 KB
/
conn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package yolotriton
import (
"context"
"time"
triton "github.com/dev6699/yolotriton/grpc-client"
)
func ServerLiveRequest(client triton.GRPCInferenceServiceClient) (*triton.ServerLiveResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
serverLiveRequest := triton.ServerLiveRequest{}
serverLiveResponse, err := client.ServerLive(ctx, &serverLiveRequest)
if err != nil {
return nil, err
}
return serverLiveResponse, nil
}
func ServerReadyRequest(client triton.GRPCInferenceServiceClient) (*triton.ServerReadyResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
serverReadyRequest := triton.ServerReadyRequest{}
serverReadyResponse, err := client.ServerReady(ctx, &serverReadyRequest)
if err != nil {
return nil, err
}
return serverReadyResponse, nil
}
func ModelMetadataRequest(client triton.GRPCInferenceServiceClient, modelName string, modelVersion string) (*triton.ModelMetadataResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
modelMetadataRequest := triton.ModelMetadataRequest{
Name: modelName,
Version: modelVersion,
}
modelMetadataResponse, err := client.ModelMetadata(ctx, &modelMetadataRequest)
if err != nil {
return nil, err
}
return modelMetadataResponse, nil
}
func ModelInferRequest(client triton.GRPCInferenceServiceClient, modelInferRequest *triton.ModelInferRequest) (*triton.ModelInferResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
modelInferResponse, err := client.ModelInfer(ctx, modelInferRequest)
if err != nil {
return nil, err
}
return modelInferResponse, nil
}