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

[RHOAIENG-11349] - Missing requirements.txt for modelmesh-runtime-adpter component #65

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Stage 1: Create the developer image for the BUILDPLATFORM only
###############################################################################
ARG GOLANG_VERSION=1.21
ARG BUILD_BASE=develop
FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION AS develop

ARG PROTOC_VERSION=21.5
Expand Down Expand Up @@ -77,6 +78,8 @@ RUN set -eux; \
WORKDIR /opt/app

COPY go.mod go.sum ./
# Download dependencies before copying the source so they will be cached
RUN go mod download

# Install go protoc plugins
# no required module provides package google.golang.org/grpc/cmd/protoc-gen-go-grpc
Expand All @@ -98,8 +101,6 @@ RUN git init && \
git config --global --add safe.directory "*" && \
rm -rf .git

# Download dependencies before copying the source so they will be cached
RUN go mod download

# the ubi/go-toolset image doesn't define ENTRYPOINT or CMD, but we need it to run 'make develop'
CMD /bin/bash
Expand All @@ -108,10 +109,18 @@ CMD /bin/bash
###############################################################################
# Stage 2: Run the go build with BUILDPLATFORM's native go compiler
###############################################################################
FROM --platform=$BUILDPLATFORM develop AS build
FROM --platform=$BUILDPLATFORM $BUILD_BASE AS build

LABEL image="build"

USER root

# needed for konflux as the previous stage is not used
WORKDIR /opt/app
COPY go.mod go.sum ./
# Download dependencies before copying the source so they will be cached
RUN go mod download

# Copy the source
COPY . ./

Expand Down Expand Up @@ -146,7 +155,7 @@ USER root
# install python to convert keras to tf
# NOTE: tensorflow not supported on PowerPC (ppc64le) or System Z (s390x) https://github.com/tensorflow/tensorflow/issues/46181
RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
microdnf install --setopt=cachedir=/root/.cache/microdnf \
microdnf install --setopt=cachedir=/root/.cache/microdnf --setopt=ubi-8-appstream-rpms.module_hotfixes=1 \
gcc \
gcc-c++ \
python38-devel \
Expand All @@ -157,17 +166,11 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \

# need to upgrade pip and install wheel before installing grpcio, before installing tensorflow on aarch64
# use caching to speed up multi-platform builds
COPY requirements.txt requirements.txt
ENV PIP_CACHE_DIR=/root/.cache/pip
RUN --mount=type=cache,target=/root/.cache/pip \
spolti marked this conversation as resolved.
Show resolved Hide resolved
pip install --upgrade pip && \
pip install wheel && \
spolti marked this conversation as resolved.
Show resolved Hide resolved
pip install grpcio && \
# pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \
# if not version is set, it will install the 3.11.0 version which, seems that does not have the h5py dependencies \
# for arm yet.
pip install h5py==3.10.0 && \
pip install tensorflow

pip install -r requirements.txt
RUN rm -rfv requirements.txt
USER ${USER}

# Add modelmesh version
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ all: build
.PHONY: build
## Build runtime Docker image
build:
./scripts/build_docker.sh --target runtime
./scripts/build_docker.sh --target builder --target runtime

.PHONY: build.develop
## Build developer container image
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,33 @@ modelmesh-controller-64f5c8d6d6-k6rzc kserve/modelmesh-controller:lat
modelmesh-serving-mlserver-1.x-84884c6849-s8dw6 kserve/rest-proxy:latest, seldonio/mlserver:1.3.2, your-docker-userid/modelmesh-runtime-adapter:dev, kserve/modelmesh:latest
modelmesh-serving-mlserver-1.x-84884c6849-xpdw4 kserve/rest-proxy:latest, seldonio/mlserver:1.3.2, your-docker-userid/modelmesh-runtime-adapter:dev, kserve/modelmesh:latest
```

# Konflux build system Files

This directory holds the requirements.txt file use in the Konflux builds to pre-fetch the required packages.

Here are two files that we need to keep:

- **requirements.txt**: is the result of the `pip freeze` command (see example below).

## How to update the requirements.txt file

Once the final container is built, you can access it:

```bash
podman run <modelmesh-runtime-adapter-container-name> sh -c 'pip freeze'
```

Note, for `tensorflow-io-gcs-filesystem` it must be pinned to **0.34.0** manually after generating the `requirements.txt` file.`

Then commit the changes and push.

# Konflux configuration

Build configuration, it requires the build be configured as follows:

```yaml
- name: prefetch-input
value: |
[{"type": "gomod"}, {"type": "rpm"}, {"type": "pip", "path": ".", "requirements_files": ["requirements.txt"], "allow_binary": "true"}]
```
45 changes: 45 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
absl-py==2.1.0
astunparse==1.6.3
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.3.2
flatbuffers==24.3.25
gast==0.4.0
google-auth==2.34.0
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.66.1
# pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \
# if not version is set, it will install the 3.11.0 version which, seems that does not have the h5py dependencies \
# for arm yet.
h5py==3.10.0
idna==3.8
importlib-metadata==8.4.0
keras==2.13.1
libclang==18.1.1
Markdown==3.7
MarkupSafe==2.1.5
numpy==1.24.3
oauthlib==3.2.2
opt-einsum==3.3.0
packaging==24.1
protobuf==4.25.4
pyasn1==0.6.0
pyasn1-modules==0.4.0
requests==2.32.3
requests-oauthlib==2.0.0
rsa==4.9
six==1.16.0
tensorboard==2.13.0
tensorboard-data-server==0.7.2
tensorflow==2.13.1
tensorflow-estimator==2.13.0
# Note, for `tensorflow-io-gcs-filesystem` it must be pinned to 0.34.0 manually after generating the `requirements.txt` file.
tensorflow-io-gcs-filesystem==0.34.0
termcolor==2.4.0
typing-extensions==4.5.0
urllib3==2.2.2
werkzeug==3.0.4
wheel==0.44.0
wrapt==1.16.0
zipp==3.20.1
Loading