Skip to content
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
32 changes: 25 additions & 7 deletions .github/workflows/ci_edge_camera.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI edge_camera
run-name: edge_camera CI on branch >> ${{ github.ref_name }} <<
name: CI edge-camera
run-name: edge-camera CI on branch >> ${{ github.ref_name }} <<

on:
workflow_dispatch:
Expand All @@ -19,21 +19,21 @@ jobs:
contents: read
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "latest"

- name: Install dependencies
run: make install
working-directory: ./edge/camera

- name: Lint with flake8 and black
- name: Lint with ruff
run: make check
working-directory: ./edge/camera

Expand All @@ -48,3 +48,21 @@ jobs:
name: Unit tests report in Python ${{ matrix.python-version }}
path: edge/camera/reports/pytest/unit-tests-report.xml
reporter: java-junit

build_and_push_images:
needs: lint_and_test_on_edge_camera
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./edge/camera/Dockerfile
image: ghcr.io/${{ github.repository }}/edge_camera
context: ./edge/camera
uses: ./.github/workflows/template_build_and_push_docker_images.yml
with:
context: ${{ matrix.context }}
dockerfile: ${{ matrix.dockerfile }}
image: ${{ matrix.image }}
secrets:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
18 changes: 9 additions & 9 deletions .github/workflows/ci_edge_model_serving.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI edge_model_serving
run-name: edge_model_serving CI on branch >> ${{ github.ref_name }} <<
name: CI edge-model-server
run-name: edge-model-server CI on branch >> ${{ github.ref_name }} <<

on:
workflow_dispatch:
Expand All @@ -12,30 +12,30 @@ on:

jobs:
lint_and_test_on_edge_model_serving:
name: Run Python linter and tests (unit > integration > functional)
name: Run Python linter and tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "latest"

- name: Install dependencies
run: make install
working-directory: ./edge/model_serving/tflite_serving

- name: Lint with flake8 and black
- name: Lint with ruff
run: make check
working-directory: ./edge/model_serving/tflite_serving

- name: Run unit tests
run: make tflite_tests
run: make unit_tests
working-directory: ./edge/model_serving/tflite_serving

- name: Upload unit test report
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci_edge_orchestrator.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI edge_orchestrator
run-name: edge_orchestrator CI on branch >> ${{ github.ref_name }} <<
name: CI edge-orchestrator
run-name: edge-orchestrator CI on branch >> ${{ github.ref_name }} <<

on:
workflow_dispatch:
Expand All @@ -20,7 +20,7 @@ jobs:
packages: read
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.11"]
services:
edge_tflite_serving:
image: ghcr.io/octo-technology/vio/edge_tflite_serving:main
Expand All @@ -34,16 +34,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "latest"

- name: Install dependencies
run: make install
working-directory: ./edge/orchestrator

- name: Lint with flake8 and black
- name: Lint with ruff
run: make check
working-directory: ./edge/orchestrator
- name: Run unit tests
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/template_build_and_push_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ jobs:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
tags: |
Expand All @@ -62,3 +62,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
30 changes: 6 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,11 @@ services:
- edge_orchestrator

hub_labelizer:
container_name: hub_labelizer
build:
context: hub/labelizer
dockerfile: Dockerfile
volumes:
- ./edge/orchestrator/data:/edge_orchestrator/data
ports:
- 8100:8100
environment:
API_CONFIG: docker
EDGE_ORCHESTRATOR_URL: http://edge_orchestrator:8000
profiles: [hub]
extends:
file: hub/labelizer/hub_labelizer.yml
service: hub_labelizer

hub_streamlit:
container_name: hub_streamlit
build:
context: hub/streamlit
dockerfile: Dockerfile
ports:
- 8500:8500
environment:
BUCKET_NAME: tf-vio-bucket
GOOGLE_APPLICATION_CREDENTIALS: /hub_streamlit/config/secrets/credentials.json
volumes:
- ./hub/streamlit/config:/hub_streamlit/config
profiles: [hub]
extends:
file: hub/streamlit/hub_streamlit.yml
service: hub_streamlit
13 changes: 13 additions & 0 deletions edge/camera/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG PYTHON_VERSION="3.11"

FROM --platform=$TARGETPLATFORM python:${PYTHON_VERSION}-slim-bookworm

Check warning on line 3 in edge/camera/Dockerfile

View workflow job for this annotation

GitHub Actions / build_and_push_images (./edge/camera/Dockerfile, ghcr.io/octo-technology/VIO/edge_camera, ./edge/... / Build and push Docker images to multiple registries

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

WORKDIR /edge_camera

COPY pyproject.toml ./
COPY src/ ./src/

RUN pip install --no-cache-dir uv && uv pip install --system -e "."

EXPOSE 8001
CMD ["uvicorn", "edge_camera.interface.api.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8001"]
23 changes: 9 additions & 14 deletions edge/camera/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,30 @@ help:
grep -E '^\.PHONY: [a-zA-Z0-9_-]+ .*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = "(: |##)"}; {printf "\033[36m%-30s\033[0m %s\n", $$2, $$3}'

.PHONY: lint ## 🐍 Lint Python files to conform to the PEP 8 style guide
.PHONY: lint ## 🐍 Lint and format Python files
lint:
autoflake --in-place --remove-all-unused-imports --recursive --ignore-init-module-imports src tests --exclude .venv
isort src tests --skip-gitignore
black src tests
uv run --no-project ruff check --fix src tests
uv run --no-project ruff format src tests

.PHONY: check ## 🐍 Check lint Python files to conform to the PEP 8 style guide
.PHONY: check ## 🐍 Check lint and format (no changes)
check:
autoflake --in-place --remove-all-unused-imports --recursive --ignore-init-module-imports src tests --exclude .venv --check
isort src tests --skip-gitignore --check
black src tests --check
flake8 --count --show-source --statistics src tests
uv run --no-project ruff check src tests
uv run --no-project ruff format --check src tests

.PHONY: install ## ⏬ Install development dependencies
install:
python -m pip install --upgrade pip setuptools
pip install -e .[dev]
pip list --outdated
uv venv && uv pip install -e ".[dev]"

.PHONY: serve ## 🚀 Run the camera service locally (CAMERA_BACKENDS=cam_1=fake by default)
serve:
uvicorn edge_camera.interface.api.app:create_app --factory \
uv run --no-project uvicorn edge_camera.interface.api.app:create_app --factory \
--host 0.0.0.0 --port 8001 --reload

.PHONY: unit_tests ## ✅ Launch the unit tests
unit_tests: REPORTS_PATH:=reports/pytest
unit_tests:
echo "[*] Running unit tests and computing code coverage..."
pytest -v --cov=src --cov-report=html:${REPORTS_PATH}/unit-tests-coverage \
uv run --no-project pytest -v --cov=src --cov-report=html:${REPORTS_PATH}/unit-tests-coverage \
--junitxml=${REPORTS_PATH}/unit-tests-report.xml \
tests/unit_tests
echo "[*] Reports available in:"
Expand Down
9 changes: 9 additions & 0 deletions edge/camera/edge_camera.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
edge_camera:
container_name: edge_camera
build:
context: .
dockerfile: Dockerfile
ports:
- 8001:8001
profiles: [edge]
22 changes: 9 additions & 13 deletions edge/camera/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ requires = ["setuptools>=66", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "edge_camera"
name = "edge-camera"
version = "1.0.0"
description = "vio-edge: camera service — standalone HTTP capture service"
description = "VIO edge camera service — standalone HTTP capture service"
requires-python = ">=3.9"
dependencies = [
"fastapi[all]==0.115.6",
Expand All @@ -14,15 +14,11 @@ dependencies = [
]

[project.optional-dependencies]
opencv = ["opencv-python-headless>=4.8.0"]
raspberry = ["picamera2==0.3.25"]
pi = ["picamera2==0.3.25; sys_platform == 'linux'"]
usb = ["opencv-python-headless>=4.8.0"]
basler = ["pypylon==4.0.0"]
dev = [
"autoflake==2.3.1",
"behave==1.3.3",
"black==24.10.0",
"flake8==7.1.1",
"isort==5.13.2",
"ruff>=0.9.0",
"numpy>=1.24.0",
"pytest==8.3.4",
"pytest-asyncio==0.25.3",
Expand All @@ -36,12 +32,12 @@ edge_camera = "edge_camera.__main__:run"
[tool.setuptools.packages.find]
where = ["src/"]

[tool.black]
[tool.ruff]
line-length = 120
target-version = ["py310", "py311", "py312", "py313"]
target-version = "py311"

[tool.isort]
profile = "black"
[tool.ruff.lint]
select = ["E", "F", "I"]

[tool.pytest.ini_options]
testpaths = "tests"
Expand Down
30 changes: 11 additions & 19 deletions edge/model_serving/tflite_serving/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,24 @@ help:
grep -E '^\.PHONY: [a-zA-Z0-9_-]+ .*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = "(: |##)"}; {printf "\033[36m%-30s\033[0m %s\n", $$2, $$3}'

.PHONY: lint ## 🐍 Lint Python files to conform to the PEP 8 style guide
.PHONY: lint ## 🐍 Lint and format Python files
lint:
autoflake --in-place --remove-all-unused-imports --recursive --ignore-init-module-imports src tests convert_pb_to_tflite.py --exclude .venv
isort src tests convert_pb_to_tflite.py --skip-gitignore
black src tests convert_pb_to_tflite.py
uv run --no-project ruff check --fix src tests
uv run --no-project ruff format src tests

.PHONY: check ## 🐍 Check lint Python files to conform to the PEP 8 style guide
.PHONY: check ## 🐍 Check lint and format (no changes)
check:
autoflake --in-place --remove-all-unused-imports --recursive --ignore-init-module-imports src tests convert_pb_to_tflite.py --exclude .venv --check
isort src tests convert_pb_to_tflite.py --skip-gitignore --check
black src tests convert_pb_to_tflite.py --check
flake8 --count --show-source --statistics

.PHONY: tflite_serving ## 🐍 Create a tflite conda environment
tflite_serving:
conda create --name tflite_serving python=3.10 -y
uv run --no-project ruff check src tests
uv run --no-project ruff format --check src tests

.PHONY: install ## ⏬ Install development dependencies
install:
python -m pip install --upgrade pip setuptools
pip install -e .[dev] && pip list --outdated
uv venv && uv pip install -e ".[dev]"

.PHONY: tflite_tests ## ✅ Launch the unit tflite_tests
tflite_tests:
pytest -v --cov=src --junitxml=reports/tests-report.xml tests/
.PHONY: unit_tests ## ✅ Launch the unit tests
unit_tests:
uv run --no-project pytest -v --cov=src --junitxml=reports/tests-report.xml tests/

.PHONY: serve ## 🚀 Run the model server locally (port 8501)
serve:
uvicorn tflite_serving.tflite_server:app --reload --port 8501 --host 0.0.0.0
uv run --no-project uvicorn tflite_serving.tflite_server:app --host 0.0.0.0 --port 8501 --reload
Loading
Loading