Skip to content

Commit

Permalink
Evam integration (#108)
Browse files Browse the repository at this point in the history
* Fix: Update Dockerfiles to Go v1.22.5 and update imgconv to generate viewable images in web from tiff (#104)

* fix: update imgconv to use latest version which resolves dep issue

* fix: imgconv and update go to v1.22.5

* fix: update test github action to use go v1.22.5
---------

Signed-off-by: Sean O'Hair <[email protected]>

* Adding EVAM compose-file

Signed-off-by: Antonio Martinez <[email protected]>

* removing build section

Signed-off-by: Antonio Martinez <[email protected]>

* progress on EVAM integration

Signed-off-by: Antonio Martinez <[email protected]>

* Progress on EVAM calls

Signed-off-by: Antonio Martinez <[email protected]>

* Implemented file and inference output

Signed-off-by: Antonio Martinez <[email protected]>

* Cleaning code

Signed-off-by: Antonio Martinez <[email protected]>

* clean up and small changes

Signed-off-by: Antonio Martinez <[email protected]>

* addressing PR review

Signed-off-by: Antonio Martinez <[email protected]>

* Adding geti container to support upload models through UI

Signed-off-by: Antonio Martinez <[email protected]>

---------

Signed-off-by: Sean O'Hair <[email protected]>
Signed-off-by: Antonio Martinez <[email protected]>
Co-authored-by: seanohair22 <[email protected]>
  • Loading branch information
antoniomtz and seanohair22 authored Aug 6, 2024
1 parent 82b812d commit 3f77155
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 91 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GOFLAGS=-ldflags "-X github.com/edgexfoundry/app-functions-sdk-go/v2/internal.SD
GIT_SHA=$(shell git rev-parse HEAD)

define COMPOSE_DOWN
docker compose -p edgex -f docker-compose-edgex.yml -f docker-compose-oem.yml -f docker-compose-gateway.yml -f docker-compose-sim.yml -f docker-compose-pipeline-val.yml -f docker-compose-geti.yml -f docker-compose-elyra.yml -f docker-compose-openvino.yml -f docker-compose-edgex-spiffe-spire.yml -f docker-compose-grpc-go.yml down $1
docker compose -p edgex -f docker-compose-edgex.yml -f docker-compose-oem.yml -f docker-compose-gateway.yml -f docker-compose-sim.yml -f docker-compose-pipeline-val.yml -f docker-compose-evam.yml -f docker-compose-geti.yml -f docker-compose-elyra.yml -f docker-compose-openvino.yml -f docker-compose-edgex-spiffe-spire.yml -f docker-compose-grpc-go.yml down $1
docker compose -p monitor -f docker-compose-monitor.yml down $1
docker compose -p log-analytics -f docker-compose-log-analytics.yml down $1
endef
Expand Down Expand Up @@ -190,6 +190,7 @@ docker-pipeline-sim:
docker build \
--build-arg http_proxy \
--build-arg https_proxy \
--no-cache \
-f ${PIPELINE_SIM}/Dockerfile \
--label "git_sha=$(GIT_SHA)" \
-t ${PROJECT}/${PIPELINE_SIM}:$(GIT_SHA) \
Expand Down Expand Up @@ -396,6 +397,7 @@ run-geti: files
-f docker-compose-oem.yml \
-f docker-compose-gateway.yml \
-f docker-compose-sim.yml \
-f docker-compose-evam.yml \
-f docker-compose-geti.yml \
up -d

Expand Down
2 changes: 1 addition & 1 deletion as-pipeline-sim/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func New(service interfaces.ApplicationService) (*Configuration, error) {
var err error
config := Configuration{}

config.GetiUrl, err = helpers.GetUrlFromAppSetting(service, "Geti", "http", false)
config.GetiUrl, err = helpers.GetUrlFromAppSetting(service, "Evam", "http", false)
if err != nil {
return nil, err
}
Expand Down
92 changes: 37 additions & 55 deletions as-pipeline-sim/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"aicsd/pkg/helpers"
"aicsd/pkg/wait"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"

"github.com/edgexfoundry/app-functions-sdk-go/v2/pkg/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
Expand All @@ -32,10 +31,12 @@ const (
OnlyResultsPipelineTopic = "only-results"
FileAndResultsPipelineName = "FileAndResults"
FileAndResultsPipelineTopic = "file-and-results"
GetiPipelineName = "GetiPipeline"
GetiPipelineName = "EvamPipeline"
GetiPipelineTopic = "geti/#"
OvmsPipelineName = "OVMS Pipeline"
PipelineStatusRunning = "Running"

EVAMPipelines = "/pipelines"
)

type PipelineSimController struct {
Expand All @@ -44,8 +45,8 @@ type PipelineSimController struct {
GetiUrl string
}

type pipelineBody struct {
Models []string `json:"models"`
type EvamBodyPipelines struct {
Version string `json:"version"`
}

func New(lc logger.LoggingClient, GetiUrl string) *PipelineSimController {
Expand Down Expand Up @@ -104,70 +105,51 @@ func (p *PipelineSimController) getPipelinesHandler(writer http.ResponseWriter,
},
}

// Get available models from GETi, skip errors if GETi container is not running
resp, err := http.Get(p.GetiUrl)
// Get available models from EVAM
getiURL := fmt.Sprintf("%s%s", p.GetiUrl, EVAMPipelines)
p.lc.Info(getiURL)

resp, err := http.Get(getiURL)
if err == nil {
body, err := io.ReadAll(resp.Body)
if err != nil {
err = werrors.WrapMsgf(err, "unable to read data from GETi")
err = werrors.WrapMsgf(err, "unable to read data from EVAM")
helpers.HandleErrorMessage(p.lc, writer, err, http.StatusInternalServerError)
}

var models pipelineBody
err = json.Unmarshal(body, &models)
var EvamPipelines []EvamBodyPipelines
err = json.Unmarshal(body, &EvamPipelines)
if err != nil {
err = werrors.WrapMsgf(err, "unable to unmarshal data from GETi")
err = werrors.WrapMsgf(err, "unable to unmarshal data from EVAM")
helpers.HandleErrorMessage(p.lc, writer, err, http.StatusInternalServerError)
}

for _, value := range models.Models {

//ignore ovms configuation file
if value == "config.json" {
continue
}

dirPath := filepath.Join("models", value, "1")

//check for existence of ovms model with sub directory 1
if _, err := os.Stat(dirPath); os.IsNotExist(err) {

//process & add geti models to pipelines
pipeline := struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SubscriptionTopic string `json:"subscriptionTopic"`
Status string `json:"status"`
}{
Id: uuid.NewString(),
Name: value + " " + GetiPipelineName,
Description: "Pipeline that calls Geti pipeline for " + value + " Detection",
SubscriptionTopic: "geti/" + value,
Status: PipelineStatusRunning,
}
pipelines = append(pipelines, pipeline)
} else {

//process & add ovms models to pipelines
pipeline := struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SubscriptionTopic string `json:"subscriptionTopic"`
Status string `json:"status"`
}{
Id: uuid.NewString(),
Name: value + " " + OvmsPipelineName,
Description: "Pipeline serving model " + value + " via BentoML service",
SubscriptionTopic: "ovms/" + value,
Status: PipelineStatusRunning,
}
pipelines = append(pipelines, pipeline)
p.lc.Info(string(len(EvamPipelines)))

for _, value := range EvamPipelines {

//process & add EVAM pipelines
pipeline := struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SubscriptionTopic string `json:"subscriptionTopic"`
Status string `json:"status"`
}{
Id: uuid.NewString(),
Name: value.Version + " " + GetiPipelineName,
Description: "Pipeline that calls EVAM for " + value.Version,
SubscriptionTopic: "geti/" + value.Version,
Status: PipelineStatusRunning,
}
pipelines = append(pipelines, pipeline)
}

defer resp.Body.Close()
} else {
err = werrors.WrapMsgf(err, "unable to reach server to query pipelines")
helpers.HandleErrorMessage(p.lc, writer, err, http.StatusInternalServerError)
return
}

data, err := json.Marshal(pipelines)
Expand Down
Loading

0 comments on commit 3f77155

Please sign in to comment.