Skip to content

Commit

Permalink
[RHOAIENG-11349] - Missing requirements.txt for modelmesh-runtime-ada…
Browse files Browse the repository at this point in the history
…pter component

chore:  Add the requirements.txt file and steps to generate it and correctly configure
        the Konflux build.
	Plus, adapt the Dockerfile to work properly witn Konflux.

Signed-off-by: Spolti <[email protected]>
  • Loading branch information
spolti committed Sep 9, 2024
1 parent d89a13d commit 8788f9b
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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 +100,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 @@ -112,6 +112,14 @@ FROM --platform=$BUILDPLATFORM develop 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 +154,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 @@ -159,7 +167,6 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
# use caching to speed up multi-platform builds
ENV PIP_CACHE_DIR=/root/.cache/pip
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip && \
pip install wheel && \
pip install grpcio && \
# pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \
Expand Down
71 changes: 71 additions & 0 deletions konflux-files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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 export` command (see example below).
- **requirements-build.txt**: secondary list of dependencies needed by the build stage.

## 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'
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
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-cpu-aws==2.13.1
tensorflow-estimator==2.13.0
tensorflow-io-gcs-filesystem==0.35.0
termcolor==2.4.0
typing-extensions==4.5.0
urllib3==2.2.2
werkzeug==3.0.4
wrapt==1.16.0
zipp==3.20.1
```

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": "konflux-files", "requirements_files": ["requirements.txt", "requirements-build.txt"], "allow_binary": "true"}]
```
18 changes: 18 additions & 0 deletions konflux-files/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Spolti <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
grpcio = "1.65.5"
h5py = "3.10.0"
tensorflow = "2.13.1"
docutils = "0.20.1"
tensorflow-io-gcs-filesystem = "0.34.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 3 additions & 0 deletions konflux-files/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wheel==0.44.0
setuptools==73.0.1

42 changes: 42 additions & 0 deletions konflux-files/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
absl-py==2.1.0
astunparse==1.6.3
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.3.2
docutils==0.20.1
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.65.5
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
tensorflow-io-gcs-filesystem==0.34.0
termcolor==2.4.0
typing_extensions==4.5.0
urllib3==2.2.2
Werkzeug==3.0.4
wrapt==1.16.0
zipp==3.20.1

0 comments on commit 8788f9b

Please sign in to comment.