-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a object_detection_client workflow file
Signed-off-by: greg pereira <[email protected]>
- Loading branch information
1 parent
958fdfa
commit f7779c4
Showing
12 changed files
with
188 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
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 | ||
REGISTRY_ORG: containers | ||
RECIPE_NAME: object_detection | ||
RECIPE_TYPE: computer_vision | ||
IMAGE_NAME: object_detection_client | ||
|
||
jobs: | ||
chatbot-build-and-push: | ||
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')" | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
services: | ||
registry: | ||
image: registry:2.8.3 | ||
ports: | ||
- 5000:5000 | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- 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/[email protected] | ||
with: | ||
image: ${{ env.REGISTRY }}/${{ env.REGISTRY_ORG }}/${{ env.IMAGE_NAME }} | ||
tags: latest | ||
platforms: linux/amd64,linux/arm64 | ||
containerfiles: ./recipes/${{ env.RECIPE_TYPE }}/${{ env.RECIPE_NAME }}/app/Containerfile | ||
context: recipes/${{ env.RECIPE_TYPE }}/${{ env.RECIPE_NAME }}/app | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Dependencies | ||
working-directory: ./recipes/${{ env.RECIPE_TYPE }}/${{ env.RECIPE_NAME }} | ||
run: make install | ||
|
||
- name: Download model | ||
working-directory: ./models | ||
run: make download-model-facebook-detr-resnet-101 | ||
|
||
- name: Run Functional Tests | ||
shell: bash | ||
run: make functional-tests | ||
working-directory: ./recipes/${{ env.RECIPE_TYPE }}/${{ env.RECIPE_NAME }} | ||
|
||
- name: Login to Registry | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: redhat-actions/[email protected] | ||
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/[email protected] | ||
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SHELL := /bin/bash | ||
APP ?= object_detection_client | ||
PORT ?= 8501 | ||
MODEL_NAME ?= facebook/detr-resnet-101 | ||
|
||
# .PHONY: functional-tests | ||
# functional-tests: | ||
# IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(RECIPE_BINARIES_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \ | ||
include ../../common/Makefile.common | ||
|
||
RECIPE_BINARIES_PATH := $(shell realpath ../../common/bin) | ||
RELATIVE_MODELS_PATH := ../../../models | ||
RELATIVE_TESTS_PATH := ../tests | ||
|
54 changes: 0 additions & 54 deletions
54
recipes/computer_vision/object_detection/tests/conftest.py
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import pytest | ||
import os | ||
|
||
|
||
@pytest.fixture | ||
def chrome_options(chrome_options): | ||
chrome_options.add_argument("--headless") | ||
return chrome_options |
File renamed without changes.
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,58 @@ | ||
import pytest_container | ||
import os | ||
import logging | ||
|
||
REGISTRY=os.environ['REGISTRY'] | ||
IMAGE_NAME=os.environ['IMAGE_NAME'] | ||
MODEL_NAME=os.environ['MODEL_NAME'] | ||
|
||
logging.info(""" | ||
Starting pytest with the following ENV vars: | ||
REGISTRY: {REGISTRY} | ||
IMAGE_NAME: {IMAGE_NAME} | ||
MODEL_NAME: {MODEL_NAME} | ||
For: | ||
model_server: whispercpp | ||
""".format(REGISTRY=REGISTRY, IMAGE_NAME=IMAGE_NAME, MODEL_NAME=MODEL_NAME)) | ||
|
||
|
||
MS = pytest_container.Container( | ||
url=f"containers-storage:{REGISTRY}/{IMAGE_NAME}", | ||
volume_mounts=[ | ||
pytest_container.container.BindMount( | ||
container_path=f"/locallm/models/${MODEL_NAME}", | ||
host_path=f"./{MODEL_NAME}", | ||
flags=["ro"] | ||
) | ||
], | ||
extra_environment_variables={ | ||
"MODEL_PATH": f"/locall/models/{MODEL_NAME}", | ||
"HOST": "0.0.0.0", | ||
"PORT": "8001" | ||
}, | ||
forwarded_ports=[ | ||
pytest_container.PortForwarding( | ||
container_port=8001, | ||
host_port=8001 | ||
) | ||
], | ||
) | ||
|
||
CB = pytest_container.Container( | ||
url=f"containers-storage:{os.environ['REGISTRY']}/containers/{os.environ['IMAGE_NAME']}", | ||
extra_environment_variables={ | ||
"MODEL_ENDPOINT": "http://10.88.0.1:8001" | ||
}, | ||
forwarded_ports=[ | ||
pytest_container.PortForwarding( | ||
container_port=8501, | ||
host_port=8501 | ||
) | ||
], | ||
) | ||
|
||
def pytest_generate_tests(metafunc): | ||
pytest_container.auto_container_parametrize(metafunc) | ||
|
||
def pytest_addoption(parser): | ||
pytest_container.add_logging_level_options(parser) |
9 changes: 7 additions & 2 deletions
9
...sion/object_detection/tests/test_alive.py → ...puter_vision/tests/functional/test_app.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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import pytest_container | ||
from .conftest import MS | ||
from .conftest import CB | ||
import tenacity | ||
|
||
CONTAINER_IMAGES = [MS] | ||
CONTAINER_IMAGES = [CB] | ||
|
||
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() | ||
|
||
def test_title(auto_container: pytest_container.container.ContainerData, selenium): | ||
selenium.get(f"http://localhost:{auto_container.forwarded_ports[0].host_port}") | ||
assert selenium.title == "Streamlit" | ||
|
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,7 @@ | ||
import os | ||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def url(): | ||
return os.environ["URL"] |
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,3 @@ | ||
def test_title(url,selenium): | ||
selenium.get(f"http://{url}:8501") | ||
assert selenium.title == "Streamlit" |
File renamed without changes.