-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
object detection recipe and MS tests
Signed-off-by: greg pereira <grpereir@redhat.com> Signed-off-by: Gregory-Pereira <grpereir@redhat.com> Signed-off-by: greg pereira <grpereir@redhat.com>
- Loading branch information
1 parent
1f73db4
commit ef90ea3
Showing
18 changed files
with
297 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: object_detection | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- ./recipes/computer_vision/object_detection/** | ||
- .github/workflows/object_detection.yaml | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- ./recipes/computer_vision/object_detection/** | ||
- .github/workflows/object_detection.yaml | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: object_detection | ||
COMPONENT: app | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
services: | ||
registry: | ||
image: registry:2.8.3 | ||
ports: | ||
- 5000:5000 | ||
steps: | ||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: Install qemu dependency | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y qemu-user-static | ||
- name: Build Image | ||
id: build_image | ||
uses: redhat-actions/buildah-build@v2.13 | ||
with: | ||
image: ${{ env.REGISTRY }}/${{ github.event.repository.name }}/${{ env.COMPONENT }}/${{ env.IMAGE_NAME }} | ||
tags: latest | ||
platforms: linux/amd64, linux/arm64 | ||
containerfiles: ./recipes/computer_vision/${{ env.IMAGE_NAME }}/app/Containerfile | ||
context: recipes/computer_vision/${{ env.IMAGE_NAME }}/app | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5.0.0 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Dependencies | ||
working-directory: ./recipes/computer_vision/${{ env.IMAGE_NAME }} | ||
run: make install | ||
|
||
- name: Download model | ||
working-directory: ./model_servers/object_detection_python | ||
run: make download-model-facebook-detr-resnet-101 | ||
|
||
# COMING SOON | ||
# - name: Run Functional Tests | ||
# shell: bash | ||
# run: make functional-tests | ||
# working-directory: ./recipes/computer_vision/${{ env.IMAGE_NAME }} | ||
|
||
- name: Login to Registry | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: redhat-actions/podman-login@v1.7 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push Image | ||
id: push_image | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: redhat-actions/push-to-registry@v2.8 | ||
with: | ||
image: ${{ steps.build_image.outputs.image }} | ||
tags: ${{ steps.build_image.outputs.tags }} | ||
registry: ${{ env.REGISTRY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
FROM registry.access.redhat.com/ubi9/python-311:1-52.1712567218 | ||
ARG PORT=8000 | ||
WORKDIR /app | ||
COPY src/requirements.txt . | ||
COPY src . | ||
RUN pip install --upgrade pip && \ | ||
pip install --no-cache-dir --upgrade -r requirements.txt | ||
COPY src/object_detection_server.py . | ||
EXPOSE $PORT | ||
ENTRYPOINT [ "uvicorn", "object_detection_server:app", "--host", "0.0.0.0" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest_container | ||
import os | ||
|
||
if not 'IMAGE' in os.environ: | ||
IMAGE = 'ghcri.io/containers/model_servers/object_detection_python:latest' | ||
else: | ||
IMAGE = os.environ['IMAGE'] | ||
|
||
if not 'MODEL_NAME' in os.environ: | ||
MODEL_NAME = 'facebook/detr-resnet-101' | ||
else: | ||
MODEL_NAME = os.environ['MODEL_NAME'] | ||
|
||
if not 'MODELS_DIR' in os.environ: | ||
MODEL_PATH = "/models" | ||
else: | ||
MODEL_PATH = os.environ['MODELS_DIR'] | ||
|
||
if not 'PORT' in os.environ: | ||
PORT = 8000 | ||
else: | ||
PORT = os.environ['PORT'] | ||
try: | ||
PORT = int(PORT) | ||
except: | ||
PORT = 8000 | ||
|
||
MS = pytest_container.Container( | ||
url=f"containers-storage:{IMAGE}", | ||
volume_mounts=[ | ||
pytest_container.container.BindMount( | ||
container_path=f"{MODEL_PATH}", | ||
host_path=f"./{MODEL_NAME}", | ||
flags=["ro"] | ||
) | ||
], | ||
extra_environment_variables={ | ||
"MODEL_PATH": f"{MODEL_PATH}", | ||
"HOST": "0.0.0.0", | ||
"PORT": f"{PORT}" | ||
}, | ||
forwarded_ports=[ | ||
pytest_container.PortForwarding( | ||
container_port=PORT, | ||
host_port=PORT | ||
) | ||
], | ||
) | ||
|
||
def pytest_generate_tests(metafunc): | ||
pytest_container.auto_container_parametrize(metafunc) | ||
|
||
def pytest_addoption(parser): | ||
pytest_container.add_logging_level_options(parser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pip==24.0 | ||
pytest-container==0.4.0 | ||
pytest-selenium==4.1.0 | ||
pytest-testinfra==10.1.0 | ||
pytest==8.1.1 | ||
requests==2.31.0 | ||
selenium==4.19.0 | ||
tenacity==8.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest_container | ||
from .conftest import MS | ||
import tenacity | ||
import os | ||
|
||
CONTAINER_IMAGES = [MS] | ||
|
||
def test_etc_os_release_present(auto_container: pytest_container.container.ContainerData): | ||
assert auto_container.connection.file("/etc/os-release").exists | ||
|
||
@tenacity.retry(stop=tenacity.stop_after_attempt(5), wait=tenacity.wait_exponential()) | ||
def test_alive(auto_container: pytest_container.container.ContainerData, host): | ||
host.run_expect([0],f"curl http://localhost:{auto_container.forwarded_ports[0].host_port}/detection",).stdout.strip() |
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
recipes/computer_vision/object_detection/app/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
altair==5.3.0 | ||
attrs==23.2.0 | ||
blinker==1.7.0 | ||
cachetools==5.3.3 | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
click==8.1.7 | ||
gitdb==4.0.11 | ||
GitPython==3.1.43 | ||
idna==3.7 | ||
Jinja2==3.1.3 | ||
jsonschema==4.21.1 | ||
jsonschema-specifications==2023.12.1 | ||
markdown-it-py==3.0.0 | ||
MarkupSafe==2.1.5 | ||
mdurl==0.1.2 | ||
numpy==1.26.4 | ||
packaging==24.0 | ||
pandas==2.2.2 | ||
pillow==10.3.0 | ||
protobuf==4.25.3 | ||
pyarrow==15.0.2 | ||
pydeck==0.8.1b0 | ||
Pygments==2.17.2 | ||
python-dateutil==2.9.0.post0 | ||
pytz==2024.1 | ||
referencing==0.34.0 | ||
requests==2.31.0 | ||
rich==13.7.1 | ||
rpds-py==0.18.0 | ||
six==1.16.0 | ||
smmap==5.0.1 | ||
streamlit==1.33.0 | ||
tenacity==8.2.3 | ||
toml==0.10.2 | ||
toolz==0.12.1 | ||
tornado==6.4 | ||
typing_extensions==4.11.0 | ||
tzdata==2024.1 | ||
urllib3==2.2.1 |
3 changes: 0 additions & 3 deletions
3
recipes/computer_vision/object_detection/client/requirements.txt
This file was deleted.
Oops, something went wrong.
Empty file.
54 changes: 54 additions & 0 deletions
54
recipes/computer_vision/object_detection/tests/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest_container | ||
import pytest | ||
import os | ||
import logging | ||
import platform | ||
|
||
if 'PORT' not in os.environ: | ||
PORT = 8000 | ||
else: | ||
PORT = os.environ['PORT'] | ||
try: | ||
PORT = int(PORT) | ||
except: | ||
PORT = 8000 | ||
|
||
if 'IMAGE' not in os.environ: | ||
IMAGE = 'ghcr.io/containers/model_servers/object_detection_python:latest' | ||
else: | ||
IMAGE = os.environ['IMAGE'] | ||
|
||
MODEL_NAME=os.environ['MODEL_NAME'] | ||
MODEL_PATH=os.environ['MODEL_PATH'] | ||
|
||
BIND_MOUNT_OPTIONS = 'ro' | ||
|
||
MS = pytest_container.Container( | ||
url=f"containers-storage:{IMAGE}", | ||
volume_mounts=[ | ||
pytest_container.container.BindMount( | ||
container_path=f"{MODEL_PATH}", | ||
host_path=f"./{MODEL_NAME}", | ||
flags=[BIND_MOUNT_OPTIONS] | ||
) | ||
], | ||
extra_environment_variables={ | ||
"MODEL_NAME": f"{MODEL_NAME}", | ||
"MODEL_PATH": f"{MODEL_PATH}", | ||
"HOST": "0.0.0.0", | ||
"PORT": f"{PORT}" | ||
}, | ||
forwarded_ports=[ | ||
pytest_container.PortForwarding( | ||
container_port=PORT, | ||
host_port=PORT | ||
) | ||
], | ||
) | ||
|
||
def pytest_addoption(parser): | ||
pytest_container.add_logging_level_options(parser) | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
pytest_container.auto_container_parametrize(metafunc) |
8 changes: 8 additions & 0 deletions
8
recipes/computer_vision/object_detection/tests/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pip==24.0 | ||
pytest-container==0.4.0 | ||
pytest-selenium==4.1.0 | ||
pytest-testinfra==10.1.0 | ||
pytest==8.1.1 | ||
requests==2.31.0 | ||
selenium==4.19.0 | ||
tenacity==8.2.3 |
12 changes: 12 additions & 0 deletions
12
recipes/computer_vision/object_detection/tests/test_alive.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest_container | ||
from .conftest import MS | ||
import tenacity | ||
|
||
CONTAINER_IMAGES = [MS] | ||
|
||
def test_etc_os_release_present(auto_container: pytest_container.container.ContainerData): | ||
assert auto_container.connection.file("/etc/os-release").exists | ||
|
||
@tenacity.retry(stop=tenacity.stop_after_attempt(5), wait=tenacity.wait_exponential()) | ||
def test_alive(auto_container: pytest_container.container.ContainerData, host): | ||
host.run_expect([0],f"curl http://localhost:{auto_container.forwarded_ports[0].host_port}",).stdout.strip() |