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

Acap runtime proto image #77

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.github/test/__pycache__/
apis/
!apis/keyvaluestore.proto
!apis/wrappers
build/
build_x86_64-linux-gnu/
larod/
Expand Down
66 changes: 66 additions & 0 deletions Dockerfile.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

Corallo marked this conversation as resolved.
Show resolved Hide resolved
ARG UBUNTU_VERSION=22.04
ARG TFSERVING_VERSION=2.9.0
pataxis marked this conversation as resolved.
Show resolved Hide resolved

# Build image, genearates proto files
FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS build-image

ARG TFSERVING_VERSION

RUN <<EOF
apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
git \
&& rm -rf /var/lib/apt/lists/*
EOF

# grpcio-tools contains protoc, which allows to build the pb2.py files in the install-tf.sh script.
# Installing directly grpcio-tools result in an older version of protobuf.
# So we install first the dependencies with the desired version and then grpcio-tool without dependencies.
RUN pip install protobuf==4.21.1 six==1.16.0 grpcio==1.46.3 --no-cache-dir
RUN pip install --no-dependencies grpcio-tools==1.47.0
Corallo marked this conversation as resolved.
Show resolved Hide resolved

#Build tensorflow serving
WORKDIR /build/tf
pataxis marked this conversation as resolved.
Show resolved Hide resolved

RUN <<EOF
git clone --depth 1 --branch v${TFSERVING_VERSION} https://github.com/tensorflow/tensorflow.git
git clone --depth 1 --branch ${TFSERVING_VERSION} https://github.com/tensorflow/serving.git

TF_DIR="./tensorflow"
TFS_DIR="./serving"
OUT_DIR="./proto_utils"

mkdir $OUT_DIR

PROTO_FILES="$TF_DIR/tensorflow/core/example/*.proto
$TF_DIR/tensorflow/core/framework/*.proto \
$TF_DIR/tensorflow/core/protobuf/*.proto \
$TFS_DIR/tensorflow_serving/apis/*.proto \
"

PROTO_FILES_GRPC="$TFS_DIR/tensorflow_serving/apis/predict.proto \
$TFS_DIR/tensorflow_serving/apis/prediction_service.proto \
"

python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --python_out="$OUT_DIR" $PROTO_FILES
python3 -m grpc_tools.protoc -I "$TF_DIR" -I "$TFS_DIR" --grpc_python_out="$OUT_DIR" $PROTO_FILES_GRPC

EOF
COPY apis/wrappers/tf_proto_utils.py ./proto_utils

#Build vdo proto
WORKDIR /build/vdo
COPY apis/videocapture.proto ./
RUN mkdir ./proto_utils && python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils videocapture.proto
COPY apis/wrappers/vdo_proto_utils.py ./proto_utils

#Build keyvalue proto
WORKDIR /build/param
COPY apis/keyvaluestore.proto ./
RUN mkdir ./proto_utils && python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils keyvaluestore.proto




Corallo marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ If you are new to the world of ACAPs take a moment to check out
- [Installation and usage](#installation-and-usage)
- [Installation](#installation)
- [Native ACAP application](#native-acap-application)
- [Installation of version 1.2.0 and previous](#installation-of-version-120-and-previous)
- [Containerized version](#containerized-version)
- [Configuration](#configuration)
- [Native ACAP application](#native-acap-application-1)
Expand All @@ -34,6 +33,7 @@ If you are new to the world of ACAPs take a moment to check out
- [Building ACAP Runtime](#building-acap-runtime)
- [Native ACAP application](#native-acap-application-2)
- [Containerized version](#containerized-version-2)
- [Building protofiles for Python](#building-protofiles-for-python)
- [Test suite](#test-suite)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -396,6 +396,16 @@ To build the containerized version, use either the Dockerfile `Dockerfile.armv7h
docker buildx build --file Dockerfile.<ARCH> --tag acap-runtime:<ARCH>-containerized .
```

## Building protofiles for Python

The repository includes a Dockerfile (`Dockerfile.proto`) for building the APIs protofiles for Python. The Dockerfile generates the necessary Python files from the protobuf definitions, allowing gRPC communication with the ACAP Runtime service, without the need to build the protofiles in your application.
Corallo marked this conversation as resolved.
Show resolved Hide resolved

To build the protofiles:

```sh
docker build -f Dockerfile.proto -t acap-runtime-proto:latest .
```

## Test suite

The repo contains a test suite project to verify that ACAP Runtime works as expected
Expand Down
Loading