forked from intel-retail/automated-self-checkout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model ready waiting logic to resolve issue intel-retail#331 (inte…
…l-retail#333) * feat: use ovms api to better handle model ready state * fix: resolve the issue for running multiple more than 5 pipelines - Add gRPC calls in profile-launcher to test models readiness from ovms server - Refactor how the unit-test makefile runs as now it requires google gRPC packages FIXES: intel-retail#331 * refactor: change the go module package definition from vision-self-checkout to automated-self-checkout * feat: upgrade goolge gRPC and protobuf to the latest version Signed-off-by: Jim Wang <[email protected]> --------- Signed-off-by: Jim Wang <[email protected]>
- Loading branch information
1 parent
c49d56b
commit f248acd
Showing
15 changed files
with
397 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ model_server/ | |
ssd_mobilenet_v1_coco/ | ||
__pycache__ | ||
smoke_tests_output.log | ||
grpc_predict_v2.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,19 @@ | |
# | ||
|
||
FROM golang:1.20.9-alpine3.18 AS builder | ||
RUN apk update && apk add make | ||
RUN apk update && \ | ||
apk add make autoconf libtool protobuf-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
WORKDIR /app | ||
RUN go install google.golang.org/protobuf/cmd/[email protected] | ||
RUN go install google.golang.org/grpc/cmd/[email protected] | ||
# Compile API | ||
RUN wget https://raw.githubusercontent.com/openvinotoolkit/model_server/main/src/kfserving_api/grpc_predict_v2.proto | ||
RUN echo 'option go_package = "./grpc-client";' >> grpc_predict_v2.proto | ||
RUN protoc --go_out="./" --go-grpc_out="./" ./grpc_predict_v2.proto | ||
|
||
COPY . . | ||
RUN make build-binary | ||
RUN go mod tidy && make build-binary | ||
|
||
FROM scratch as bin | ||
COPY --from=builder /app/profile-launcher / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Copyright (C) 2023 Intel Corporation. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
FROM golang:1.20.9-alpine3.18 AS builder | ||
RUN apk update && \ | ||
apk add make autoconf libtool protobuf-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
WORKDIR /test | ||
|
||
# install docker, as we need docker for some unit tests | ||
RUN apk update && apk add --update docker openrc && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . . | ||
|
||
RUN chmod +x /test/run_unit_test.sh | ||
|
||
ENTRYPOINT ["/test/run_unit_test.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
module github.com/intel-retail/vision-self-checkout/configs/opencv-ovms/cmd_client | ||
module github.com/intel-retail/automated-self-checkout/configs/opencv-ovms/cmd_client | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.8.4 | ||
google.golang.org/grpc v1.59.0 | ||
google.golang.org/protobuf v1.31.0 | ||
gopkg.in/yaml.v3 v3.0.1 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
golang.org/x/net v0.14.0 // indirect | ||
golang.org/x/sys v0.11.0 // indirect | ||
golang.org/x/text v0.12.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
configs/opencv-ovms/cmd_client/parser/ovmsConfigJsonParser.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright 2023 Intel Corp. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ---------------------------------------------------------------------------------- | ||
|
||
package parser | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
type ModelConfigInfo struct { | ||
ModelName string `json:"name"` | ||
} | ||
|
||
type ModelConfigListInfo struct { | ||
Config ModelConfigInfo `json:"config"` | ||
} | ||
|
||
type ConfigJsonModelParser struct { | ||
ModelConfigList []ModelConfigListInfo `json:"model_config_list"` | ||
|
||
configJsonFileName string | ||
configJsonDir string | ||
} | ||
|
||
func NewConfigJsonModelParser(configJsonDir, configJsonFileName string) *ConfigJsonModelParser { | ||
return &ConfigJsonModelParser{ | ||
configJsonDir: configJsonDir, | ||
configJsonFileName: configJsonFileName, | ||
} | ||
} | ||
|
||
// Parse will parse the list of model names from the file configJsonFileName under the directory configJsonDir | ||
func (cjmp *ConfigJsonModelParser) Parse() error { | ||
configJsonFile := filepath.Join(cjmp.configJsonDir, cjmp.configJsonFileName) | ||
jsonFileReader, err := os.Open(configJsonFile) | ||
if err != nil { | ||
return fmt.Errorf("failed to open OVMS config json file %s: %v", configJsonFile, err) | ||
} | ||
defer jsonFileReader.Close() | ||
|
||
contents, err := io.ReadAll(jsonFileReader) | ||
if err != nil { | ||
return fmt.Errorf("failed to read OVMS config json file %s: %v", configJsonFile, err) | ||
} | ||
|
||
if err := json.Unmarshal(contents, &cjmp); err != nil { | ||
return fmt.Errorf("failed to unmarshal OVMS config json: %v", err) | ||
} | ||
|
||
return nil | ||
} |
56 changes: 56 additions & 0 deletions
56
configs/opencv-ovms/cmd_client/parser/ovmsConfigJsonParser_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright 2023 Intel Corp. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ---------------------------------------------------------------------------------- | ||
|
||
package parser | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
jsonFileDir string | ||
jsonFileName string | ||
expectError bool | ||
}{ | ||
{"current template json file", ".", "test-config_template.json", false}, | ||
{"invalid json content", ".", "test-invalid.json", true}, | ||
{"non-existing json file", ".", "non-existing.json", true}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
configParser := NewConfigJsonModelParser(tt.jsonFileDir, tt.jsonFileName) | ||
|
||
err := configParser.Parse() | ||
if !tt.expectError { | ||
require.NoError(t, err) | ||
require.NotEmpty(t, configParser) | ||
require.Contains(t, configParser.ModelConfigList, ModelConfigListInfo{ | ||
Config: ModelConfigInfo{ | ||
ModelName: "efficientnet-b0", | ||
}, | ||
}) | ||
} else { | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.