Skip to content

Commit

Permalink
Added proto files for rnn-serving and video-analytics-standalone.
Browse files Browse the repository at this point in the history
Updated protos for all benchmarks.

Signed-off-by: L Lakshmanan <[email protected]>
  • Loading branch information
Lakshman authored and dhschall committed Jul 25, 2024
1 parent a9f922b commit c911941
Show file tree
Hide file tree
Showing 23 changed files with 1,318 additions and 477 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ replace (
github.com/vhive-serverless/vSwarm-proto/proto/hotel_reserv => ./proto/hotel_reserv
github.com/vhive-serverless/vSwarm-proto/proto/image_rotate => ./proto/image_rotate
github.com/vhive-serverless/vSwarm-proto/proto/video_processing => ./proto/video_processing
github.com/vhive-serverless/vSwarm-proto/proto/rnn_serving => ./proto/rnn_serving
github.com/vhive-serverless/vSwarm-proto/proto/video_analytics_standalone => ./proto/video_analytics_standalone
)

require (
Expand Down
10 changes: 10 additions & 0 deletions grpcclient/getclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func FindServiceName(functionName string) string {
return "image-rotate"
case "video-processing-python":
return "video-processing"
case "rnn-serving-python":
return "rnn-serving"
case "video-analytics-standalone-python":
return "video-analytics-standalone"
case "spright-parking-python":
return "spright-parking"
default:
Expand Down Expand Up @@ -55,6 +59,12 @@ func FindGrpcClient(service_name string) GrpcClient {
case "video-processing":
log.Debug("Found video processing client")
return new(VideoProcessingClient)
case "rnn-serving":
log.Debug("Found rnn serving client")
return new(RNNServingClient)
case "video-analytics-standalone":
log.Debug("Found video analytics standalone client")
return new(VideoAnalyticsClient)

// Hotel reservation ---
case "Geo", "geo":
Expand Down
74 changes: 74 additions & 0 deletions grpcclient/rnn_serving_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package grpcclient

import (
"context"
"math/rand"
"strconv"
"strings"

pb "github.com/vhive-serverless/vSwarm-proto/proto/rnn_serving"
)

type RNNServingGenerator struct {
GeneratorBase
}

func (g *RNNServingGenerator) Next() Input {

countries := []string{
"French", "Czech", "Dutch", "Polish", "Scottish", "Chinese",
"English", "Italian", "Portuguese", "Japanese", "German",
"Russian", "Korean", "Arabic", "Greek", "Vietnamese", "Spanish", "Irish",
}

var pkt = g.defaultInput

switch g.GeneratorBase.generator {
case Unique:
country := "English"
numSamples := 1
pkt.Value = country + " " + strconv.Itoa(numSamples)

case Random:
randomCountry := countries[rand.Intn(len(countries))]
var numSamples int
if g.lowerBound == g.upperBound {
numSamples = g.lowerBound
} else {
numSamples = g.lowerBound + rand.Intn(g.upperBound-g.lowerBound)
}
pkt.Value = randomCountry + " " + strconv.Itoa(numSamples)
}
return pkt
}

func (c *RNNServingClient) GetGenerator() Generator {
return new(RNNServingGenerator)
}

type RNNServingClient struct {
ClientBase
client pb.RNNServingClient
}

func (c *RNNServingClient) Init(ctx context.Context, ip, port string) error {
err := c.Connect(ctx, ip, port)
if err != nil {
return err
}
c.client = pb.NewRNNServingClient(c.conn)
return nil
}

func (c *RNNServingClient) Request(ctx context.Context, req Input) (string, error) {

inputs = strings.Split(req.Value, " ")
language := inputs[0]
numSamples, _ := strconv.ParseInt(inputs[1], 10, 32)

r, err := c.client.GenerateString(ctx, &pb.SendLanguage{Language: string(language), NumSamples: int32(numSamples)})
if err != nil {
return "", err
}
return r.GetMessage(), nil
}
42 changes: 42 additions & 0 deletions grpcclient/video_analytics_standalone_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package grpcclient

import (
"context"

pb "github.com/vhive-serverless/vSwarm-proto/proto/video_analytics_standalone"
)

type VideoAnalyticsGenerator struct {
GeneratorBase
}

func (g *VideoAnalyticsGenerator) Next() Input {
var pkt = g.defaultInput
return pkt
}

func (c *VideoAnalyticsClient) GetGenerator() Generator {
return new(VideoAnalyticsGenerator)
}

type VideoAnalyticsClient struct {
ClientBase
client pb.VideoAnalyticsClient
}

func (c *VideoAnalyticsClient) Init(ctx context.Context, ip, port string) error {
err := c.Connect(ctx, ip, port)
if err != nil {
return err
}
c.client = pb.NewVideoAnalyticsClient(c.conn)
return nil
}

func (c *VideoAnalyticsClient) Request(ctx context.Context, req Input) (string, error) {
r, err := c.client.ObjectDetection(ctx, &pb.SendVideo{Name: req.Value})
if err != nil {
return "", err
}
return r.GetMessage(), nil
}
37 changes: 10 additions & 27 deletions proto/aes/aes_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 10 additions & 27 deletions proto/auth/auth_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 10 additions & 27 deletions proto/fibonacci/fibonacci_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions proto/gptj/gptj_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions proto/gptj/gptj_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

import gptj_pb2 as gptj__pb2
from proto.gptj import gptj_pb2 as proto_dot_gptj_dot_gptj__pb2


class GptJBenchmarkStub(object):
Expand All @@ -16,8 +16,8 @@ def __init__(self, channel):
"""
self.GetBenchmark = channel.unary_unary(
'/gptj.GptJBenchmark/GetBenchmark',
request_serializer=gptj__pb2.GptJBenchmarkRequest.SerializeToString,
response_deserializer=gptj__pb2.GptJBenchmarkReply.FromString,
request_serializer=proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkRequest.SerializeToString,
response_deserializer=proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkReply.FromString,
)


Expand All @@ -35,8 +35,8 @@ def add_GptJBenchmarkServicer_to_server(servicer, server):
rpc_method_handlers = {
'GetBenchmark': grpc.unary_unary_rpc_method_handler(
servicer.GetBenchmark,
request_deserializer=gptj__pb2.GptJBenchmarkRequest.FromString,
response_serializer=gptj__pb2.GptJBenchmarkReply.SerializeToString,
request_deserializer=proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkRequest.FromString,
response_serializer=proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkReply.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
Expand All @@ -60,7 +60,7 @@ def GetBenchmark(request,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/gptj.GptJBenchmark/GetBenchmark',
gptj__pb2.GptJBenchmarkRequest.SerializeToString,
gptj__pb2.GptJBenchmarkReply.FromString,
proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkRequest.SerializeToString,
proto_dot_gptj_dot_gptj__pb2.GptJBenchmarkReply.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading

0 comments on commit c911941

Please sign in to comment.