Skip to content

Commit

Permalink
fix: docker compose up failed with "Error: configuration file not fou…
Browse files Browse the repository at this point in the history
…nd or cannot open" (intel-retail#436)

* fix: docker compose up failed with "Error: configuration file not found or cannot open"

closes: intel-retail#434
Signed-off-by: Jim Wang <[email protected]>
Signed-off-by: Valina Li <[email protected]>
  • Loading branch information
vli11 authored Jan 3, 2024
1 parent 3cde404 commit f126b81
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ run-portainer:
docker compose -p portainer -f docker-compose-portainer.yml up -d

run-pipelines:
@./scripts/gen_ovms_model_config_json.sh
docker compose -f docker-compose.yml up -d

clean:
Expand Down Expand Up @@ -114,6 +115,7 @@ down-portainer:

down-pipelines:
docker compose -f docker-compose.yml down
@rm ./configs/opencv-ovms/models/2022/config.json

clean-all: clean clean-ovms clean-simulator clean-results clean-telegraf clean-webcam down-pipelines

Expand Down
37 changes: 35 additions & 2 deletions configs/opencv-ovms/cmd_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ type OvmsClientConfig struct {
}

type Flags struct {
FlagSet *flag.FlagSet
configDir string
FlagSet *flag.FlagSet
configDir string
oVMSModelConfigDir string
}

func main() {
Expand All @@ -148,12 +149,15 @@ func main() {
}
flagSet.StringVar(&flags.configDir, "configDir", filepath.Join(".", resourceDir), "")
flagSet.StringVar(&flags.configDir, "cd", filepath.Join(".", resourceDir), "")
flagSet.StringVar(&flags.oVMSModelConfigDir, "genOVMSModelConfig", "", "")
err := flags.FlagSet.Parse(os.Args[1:])
if err != nil {
flagSet.Usage()
log.Fatalln(err)
}

flags.genOVMSModelConfig()

// the config yaml file is in res/ folder of the "pipeline profile" directory
contents, err := flags.readPipelineConfig()
if err != nil {
Expand Down Expand Up @@ -665,3 +669,32 @@ func (flags *Flags) readPipelineConfig() ([]byte, error) {

return contents, err
}

func (flags *Flags) genOVMSModelConfig() {
if len(flags.oVMSModelConfigDir) > 0 {
log.Println("generate config.json file for docker compose up case...")

deviceUpdater := server.NewDeviceUpdater(flags.oVMSModelConfigDir, ovmsTemplateConfigJson)
targetDevice := defaultTargetDevice
if len(os.Getenv(TARGET_DEVICE_ENV)) > 0 {
// only set the value from env if env is not empty; otherwise defaults to the default value in defaultTargetDevice
// devices supported CPU, GPU, GPU.x, AUTO, MULTI:GPU,CPU
targetDevice = os.Getenv(TARGET_DEVICE_ENV)
}

log.Println("Updating config with DEVICE environment variable:", targetDevice)

newUpdateConfigJson := "config.json"

if err := deviceUpdater.UpdateDeviceAndCreateJson(targetDevice, filepath.Join(flags.oVMSModelConfigDir, newUpdateConfigJson)); err != nil {
log.Printf("Error: failed to update device and produce a new ovms server config json: %v", err)
os.Exit(1)
}

configJsonContainer := filepath.Join("/models", newUpdateConfigJson)
log.Println("configJsonContainer:", configJsonContainer)
os.Exit(0)
} else {
log.Println("no OVMS Model config input, skip...")
}
}
2 changes: 1 addition & 1 deletion configs/opencv-ovms/models/2022/config_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
{
"config": {
"name": "efficientnet-b0",
"base_path": "/models/efficientnet-b0/FP32",
"base_path": "/models/efficientnet-b0/FP32-INT8",
"target_device": "{target_device}"
},
"latest": {
Expand Down
9 changes: 9 additions & 0 deletions configs/opencv-ovms/scripts/gen_ovms_model_config_json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# Copyright (C) 2023 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#

DEVICE="$DEVICE" \
./profile-launcher --genOVMSModelConfig ./configs/opencv-ovms/models/2022
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
command: "
-nostdin
-re -stream_loop -1
-i /home/pipeline-server/sample-media/couple-paying-at-the-counter-in-the-grocery-4121754-3840-15-bench.mp4
-i /home/pipeline-server/sample-media/vehicle-bike-1920-15-bench.mp4
-c copy
-f rtsp
-rtsp_transport
Expand All @@ -65,7 +65,7 @@ services:
command: "
-nostdin
-re -stream_loop -1
-i /home/pipeline-server/sample-media/vehicle-bike-3840-15-bench.mp4
-i /home/pipeline-server/sample-media/video_of_people_walking_855564-1920-15-bench.mp4
-c copy
-f rtsp
-rtsp_transport
Expand Down Expand Up @@ -106,7 +106,7 @@ services:
environment:
- CONTAINER_NAME="object-detection0"
- GRPC_PORT=9001
- INPUTSRC=rtsp://localhost:8554/camera_0
- INPUTSRC=rtsp://localhost:8554/camera_1
- cid_count=0
- DETECTION_MODEL_NAME=ssd_mobilenet_v1_coco
- DETECTION_LABEL_FILE=coco_91cl_bkgr.txt
Expand All @@ -131,7 +131,7 @@ services:
environment:
- CONTAINER_NAME="object-detection1"
- GRPC_PORT=9001
- INPUTSRC=rtsp://localhost:8554/camera_0
- INPUTSRC=rtsp://localhost:8554/camera_2
- cid_count=1
- DETECTION_MODEL_NAME=ssd_mobilenet_v1_coco
- DETECTION_LABEL_FILE=coco_91cl_bkgr.txt
Expand All @@ -156,7 +156,7 @@ services:
environment:
- CONTAINER_NAME="classification2"
- GRPC_PORT=9001
- INPUTSRC=rtsp://localhost:8554/camera_1
- INPUTSRC=rtsp://localhost:8554/camera_0
- cid_count=2
- CLASSIFICATION_MODEL_NAME=efficientnet-b0
- CLASSIFICATION_LABEL_FILE=imagenet_2012.txt
Expand Down

0 comments on commit f126b81

Please sign in to comment.