Skip to content

Commit

Permalink
feat: update python demo and name of binding
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGinn <brian.mcginn@intel.com>
  • Loading branch information
brian-intel committed Jun 3, 2024
1 parent 8059e1d commit 1d2ba0b
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 101 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ovms-build-image:
cd model_server && CHECK_COVERAGE=0 RUN_TESTS=0 make ovms_builder_image

build-capi-python:
docker build -f capi_python/Dockerfile -t capi_python_bind:dev .
docker build -f capi-python/Dockerfile -t capi-python_bind:dev --target bin --output=. .

run:
docker run -it --rm --entrypoint /bin/bash capi_python_bind:dev
docker run -it --rm -v ./capi-python:/tmp/project --entrypoint /bin/bash capi_python_bind:dev
File renamed without changes.
18 changes: 18 additions & 0 deletions capi-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# FROM openvino/model_server:2024.1-gpu
FROM openvino/model_server-build:latest AS builder

USER root

WORKDIR /
RUN git clone https://github.com/openvinotoolkit/model_server

WORKDIR /model_server

COPY capi-python/ /model_server/src/capi-python

RUN bazel build --jobs=8 //src/capi-python:ovmspybind.so

RUN mkdir -p /output && find / -name "ovmspybind.so" -exec cp "{}" /output/ovmspybind.so \;

FROM scratch as bin
COPY --from=builder /output/ovmspybind.so /
6 changes: 3 additions & 3 deletions capi_python/README.md → capi-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ find / -type f -name "pyovms.so"
find / -type f -name "ovmspybind.so"


rm /ovms/src/python/capi_python/ovmspybind.so && cp /root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/k8-opt/bin/src/python/capi_python/ovmspybind.so src/python/capi_python/
rm /ovms/src/python/capi-python/ovmspybind.so && cp /root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/k8-opt/bin/src/python/capi-python/ovmspybind.so src/python/capi-python/

python3 src/python/capi_python/ovms-pybind.py
python3 src/python/capi-python/ovms-pybind.py

bazel --output_base=$PWD/output build //src/python/capi_python:ovmspybind.so
bazel --output_base=$PWD/output build //src/python/capi-python:ovmspybind.so
8 changes: 4 additions & 4 deletions capi_python/commands.sh → capi-python/commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ find / -type f -name "pyovms.so"
find / -type f -name "ovmspybind.so"
find / -name "mytest.txt" -exec cp "{}" /output/mytest.txt \;

rm /ovms/src/python/capi_python/ovmspybind.so && cp /root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/k8-opt/bin/src/python/capi_python/ovmspybind.so src/python/capi_python/
rm /ovms/src/python/capi-python/ovmspybind.so && cp /root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/k8-opt/bin/src/python/capi-python/ovmspybind.so src/python/capi-python/

python3 src/python/capi_python/ovms-pybind.py
python3 src/python/capi-python/ovms-pybind.py

bazel --output_base=$PWD/output build //src/python/capi_python:ovmspybind.so
bazel --output_base=$PWD/output build //src/python/capi-python:ovmspybind.so

/model_serve

/root/.cache/bazel/_bazel_root/a249bbdc9c7f020e8d44a19d57754c73/execroot/ovms/bazel-out/k8-opt/bin/src/capi_python/ovmspybind.so
/root/.cache/bazel/_bazel_root/a249bbdc9c7f020e8d44a19d57754c73/execroot/ovms/bazel-out/k8-opt/bin/src/capi-python/ovmspybind.so
18 changes: 18 additions & 0 deletions capi-python/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"model_config_list": [
{
"config": {
"name": "yolov5s",
"base_path": "models/yolov5s/FP16-INT8",
"layout": "NHWC:NCHW",
"shape": "(1,416,416,3)",
"nireq": 1,
"batch_size": "1",
"plugin_config": {
"PERFORMANCE_HINT": "LATENCY"
},
"target_device": "CPU"
}
}
]
}
File renamed without changes.
9 changes: 7 additions & 2 deletions capi_python/ovms-pybind.py → capi-python/ovms-pybind.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
sys.path.insert(1, './')

import ovmspybind
import time

serverSet = ovmspybind.ServerSettingsNew()
print(serverSet.grpcPort)
Expand All @@ -11,7 +12,7 @@

modelSet = ovmspybind.ModelSettingsNew()
print(modelSet.configPath)
modelSet.configPath = "src/python/capi_python/config.json"
modelSet.configPath = "config.json"
print(modelSet.configPath)

status = ovmspybind.StatusCode.OK
Expand All @@ -24,4 +25,8 @@
print(server.isLive())
startStatus = server.start(serverSet, modelSet)
print(startStatus.getCode())
print(server.isLive())

while True:
print(server.isLive())
time.sleep(5)

18 changes: 0 additions & 18 deletions capi_python/Dockerfile

This file was deleted.

72 changes: 0 additions & 72 deletions capi_python/config.json

This file was deleted.

0 comments on commit 1d2ba0b

Please sign in to comment.