Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image classification benchmark proto #64

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ replace (
github.com/vhive-serverless/vSwarm-proto/proto/helloworld => ./proto/helloworld
github.com/vhive-serverless/vSwarm-proto/proto/hipstershop => ./proto/hipstershop
github.com/vhive-serverless/vSwarm-proto/proto/hotel_reserv => ./proto/hotel_reserv
github.com/vhive-serverless/vSwarm-proto/proto/image_classification => ./proto/image_classification
)

require (
Expand Down
5 changes: 5 additions & 0 deletions grpcclient/getclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func FindServiceName(functionName string) string {
return "auth"
case "fibonacci-go", "fibonacci-python", "fibonacci-nodejs", "fibonacci-cpp":
return "fibonacci"
case "image_classification-python":
return "image_classification"
default:
return functionName
}
Expand All @@ -33,6 +35,9 @@ func FindGrpcClient(service_name string) GrpcClient {
case "fibonacci":
log.Debug("Found Fibonacci client")
return new(FibonacciClient)
case "image_classification":
log.Debug("Found Image Classification client")
return new(ImgClassificationClient)

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

// Copyright (c) 2023 Hyscale lab

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package grpcclient

import (
"context"

log "github.com/sirupsen/logrus"
pb "github.com/vhive-serverless/vSwarm-proto/proto/image_classification"
)

type ImgClassificationGenerator struct {
GeneratorBase
}

func (g *ImgClassificationGenerator) Next() Input {
var pkt = g.defaultInput
switch g.GeneratorBase.generator {
case Unique:
pkt.Value = "A unique message"
case Linear:
pkt.Value = "A linear message"
case Random:
pkt.Value = "A random message"
}
return pkt
}

func (c *ImgClassificationClient) GetGenerator() Generator {
return new(ImgClassificationGenerator)
}

type ImgClassificationClient struct {
ClientBase
client pb.GreeterClient
}

func (c *ImgClassificationClient) Init(ctx context.Context, ip, port string) {
c.Connect(ctx, ip, port)
c.client = pb.NewGreeterClient(c.conn)
}

func (c *ImgClassificationClient) Request(ctx context.Context, req Input) string {
var message = req.Value
r, err := c.client.SayHello(ctx, &pb.HelloRequest{Name: message})
if err != nil {
log.Fatalf("could not greet: %v", err)
}

return r.GetMessage()
}
243 changes: 243 additions & 0 deletions proto/image_classification/image_classification.pb.go

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

41 changes: 41 additions & 0 deletions proto/image_classification/image_classification.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// MIT License

// Copyright (c) 2023 Hyscale lab

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

syntax = "proto3";

option go_package = "github.com/vhive-serverless/vSwarm-proto/proto/image_classification";

package image_classification;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {string message =1;}
Loading