Skip to content

Commit

Permalink
Merge pull request #82 from shiguredo/feature/mv-examples-tests
Browse files Browse the repository at this point in the history
Feature/mv examples e2e tests
  • Loading branch information
voluntas committed Sep 16, 2024
2 parents 0b1136e + 45c2733 commit 674eddf
Show file tree
Hide file tree
Showing 35 changed files with 1,249 additions and 662 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: examples-e2e-test
name: e2e-test

on:
push:
Expand All @@ -17,7 +17,7 @@ env:
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}

jobs:
e2e_ubuntu_test:
e2e_test_ubuntu:
if: >-
${{
contains(github.event.head_commit.message, '[e2e]') ||
Expand All @@ -28,10 +28,7 @@ jobs:
python_version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-22.04", "ubuntu-24.04"]
runs-on: ${{ matrix.os}}
defaults:
run:
working-directory: ./examples
timeout-minutes: 20
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
# libx11-dev は Ubuntu 24.04 の時に必要になる模様
Expand All @@ -47,12 +44,13 @@ jobs:
- uses: eifinger/setup-rye@v4
- run: rye pin ${{ matrix.python_version }}
- run: rye sync
- run: rye run python run.py ${{ matrix.os }}_x86_64
- run: rye run pytest tests/test_openh264.py -s
- run: rye run pytest tests/test_messaging.py -s
- run: rye run pytest tests/test_sendonly_recvonly.py -s
- run: rye run pytest tests/test_vad.py -s

e2e_macos_test:
e2e_test_macos:
if: >-
${{
contains(github.event.head_commit.message, '[e2e]') ||
Expand All @@ -64,10 +62,7 @@ jobs:
# macos-13 は test_macos.py が上手くテストが動かないのでスキップ
os: ["macos-14"]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./examples
timeout-minutes: 20
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Download openh264
Expand All @@ -79,13 +74,14 @@ jobs:
- uses: eifinger/setup-rye@v4
- run: rye pin ${{ matrix.python_version }}
- run: rye sync
- run: rye run python run.py macos_arm64
- run: rye run pytest tests/test_macos.py -s
- run: rye run pytest tests/test_openh264.py -s
- run: rye run pytest tests/test_messaging.py -s
- run: rye run pytest tests/test_sendonly_recvonly.py -s
- run: rye run pytest tests/test_vad.py -s

e2e_windows_test:
e2e_test_windows:
if: >-
${{
contains(github.event.head_commit.message, '[e2e]') ||
Expand All @@ -95,10 +91,7 @@ jobs:
matrix:
python_version: ["3.10", "3.11", "3.12"]
runs-on: windows-2022
defaults:
run:
working-directory: ./examples
timeout-minutes: 20
timeout-minutes: 30
env:
# Python を強制的に UTF-8 で利用するおまじない
PYTHONUTF8: 1
Expand All @@ -115,12 +108,13 @@ jobs:
- uses: eifinger/setup-rye@v4
- run: rye pin ${{ matrix.python_version }}
- run: rye sync
- run: rye run python run.py windows_x86_64
- run: rye run pytest tests/test_messaging.py -s
- run: rye run pytest tests/test_sendonly_recvonly.py -s
- run: rye run pytest tests/test_vad.py -s

slack_notify_succeeded:
needs: [e2e_ubuntu_test, e2e_macos_test, e2e_windows_test]
needs: [e2e_test_ubuntu, e2e_test_macos, e2e_test_windows]
runs-on: ubuntu-latest
if: success()
steps:
Expand All @@ -134,7 +128,7 @@ jobs:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

slack_notify_failed:
needs: [e2e_ubuntu_test, e2e_macos_test, e2e_windows_test]
needs: [e2e_test_ubuntu, e2e_test_macos, e2e_test_windows]
runs-on: ubuntu-latest
if: failure()
steps:
Expand Down
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
/_build
/_source
/_package
__pycache__/
__pycache__
.pytest_cache/
.venv/
*.egg-info/
/_skbuild
build
.ruff_cache
.mypy_cache
*.pyc

src/sora_sdk/*.so
src/sora_sdk/*.dll
Expand All @@ -19,9 +22,9 @@ src/sora_sdk/py.typed
/dist
/wheelhouse

# E2E テスト用
.env

# examples / E2E テスト用
.env*
!.env.template

# libopenh264
libopenh264*
libopenh264*
7 changes: 0 additions & 7 deletions examples/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/.python-version

This file was deleted.

13 changes: 2 additions & 11 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
rye sync
```

## サンプルの種類

- media_sendonly
- media_recvonly
- messaging_sendrecv
- messaging_sendonly
- messaging_recvonly
- hideface_sender

## サンプルコードの実行

`.env.template` をコピーして `.env` に必要な変数を設定してください。
Expand All @@ -29,8 +20,8 @@ rye sync
cp .env.template .env
```

例えば `media_recvonly` サンプルを実行する場合は以下のコマンドを実行してください
例えば `media_sendonly.py` を実行する場合は以下のコマンドを実行してください

```bash
rye run media_recvonly
rye run python3 src/media_sendonly.py
```
20 changes: 8 additions & 12 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@ dependencies = [
"opencv-python~=4.10.0.84",
"opencv-python-headless~=4.10.0.84",
"sounddevice~=0.4.7",
"sora-sdk>=2024.4.0.dev0",
"sora-sdk>=2024.3.0",
"mediapipe~=0.10.14",
"python-dotenv>=1.0.1",
"numpy>=2.0.1",
"pillow>=10.4.0",
]
readme = "README.md"
requires-python = ">= 3.10"

[project.scripts]
media_sendonly = "media.sendonly:sendonly"
media_recvonly = "media.recvonly:recvonly"
media_vad = "media.vad:vad"
messaging_sendrecv = "messaging.sendrecv:sendrecv"
messaging_sendonly = "messaging.sendonly:sendonly"
messaging_recvonly = "messaging.recvonly:recvonly"
hideface_sender = "ml.hideface_sender:hideface_sender"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = ["ruff>=0.6", "mypy>=1.10.0", "pytest>=8.3"]
dev-dependencies = [
"ruff>=0.6",
"mypy>=1.11.2",
"pytest>=8.3",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/media", "src/messaging", "src/ml"]
packages = ["src"]

[tool.ruff]
target-version = "py310"
Expand Down
21 changes: 11 additions & 10 deletions examples/requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ absl-py==2.1.0
# via mediapipe
attrs==24.2.0
# via mediapipe
cffi==1.17.0
cffi==1.17.1
# via sounddevice
contourpy==1.2.1
contourpy==1.3.0
# via matplotlib
cycler==0.12.1
# via matplotlib
Expand All @@ -33,19 +33,19 @@ jax==0.4.31
jaxlib==0.4.31
# via jax
# via mediapipe
kiwisolver==1.4.5
kiwisolver==1.4.7
# via matplotlib
matplotlib==3.9.2
# via mediapipe
mediapipe==0.10.14
# via sora-sdk-samples
ml-dtypes==0.4.0
ml-dtypes==0.5.0
# via jax
# via jaxlib
mypy==1.11.1
mypy==1.11.2
mypy-extensions==1.0.0
# via mypy
numpy==2.1.0
numpy==2.1.1
# via contourpy
# via jax
# via jaxlib
Expand All @@ -71,21 +71,22 @@ packaging==24.1
# via pytest
pillow==10.4.0
# via matplotlib
# via sora-sdk-samples
pluggy==1.5.0
# via pytest
protobuf==4.25.4
# via mediapipe
pycparser==2.22
# via cffi
pyparsing==3.1.2
pyparsing==3.1.4
# via matplotlib
pytest==8.3.2
pytest==8.3.3
python-dateutil==2.9.0.post0
# via matplotlib
python-dotenv==1.0.1
# via sora-sdk-samples
ruff==0.6.1
scipy==1.14.0
ruff==0.6.5
scipy==1.14.1
# via jax
# via jaxlib
six==1.16.0
Expand Down
15 changes: 8 additions & 7 deletions examples/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ absl-py==2.1.0
# via mediapipe
attrs==24.2.0
# via mediapipe
cffi==1.17.0
cffi==1.17.1
# via sounddevice
contourpy==1.2.1
contourpy==1.3.0
# via matplotlib
cycler==0.12.1
# via matplotlib
Expand All @@ -29,16 +29,16 @@ jax==0.4.31
jaxlib==0.4.31
# via jax
# via mediapipe
kiwisolver==1.4.5
kiwisolver==1.4.7
# via matplotlib
matplotlib==3.9.2
# via mediapipe
mediapipe==0.10.14
# via sora-sdk-samples
ml-dtypes==0.4.0
ml-dtypes==0.5.0
# via jax
# via jaxlib
numpy==2.1.0
numpy==2.1.1
# via contourpy
# via jax
# via jaxlib
Expand All @@ -63,17 +63,18 @@ packaging==24.1
# via matplotlib
pillow==10.4.0
# via matplotlib
# via sora-sdk-samples
protobuf==4.25.4
# via mediapipe
pycparser==2.22
# via cffi
pyparsing==3.1.2
pyparsing==3.1.4
# via matplotlib
python-dateutil==2.9.0.post0
# via matplotlib
python-dotenv==1.0.1
# via sora-sdk-samples
scipy==1.14.0
scipy==1.14.1
# via jax
# via jaxlib
six==1.16.0
Expand Down
Empty file removed examples/src/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from threading import Event
from typing import Any, Optional

import cv2
import mediapipe as mp
import cv2 # type: ignore
import mediapipe as mp # type: ignore
import numpy as np
from cv2.typing import MatLike
from cv2.typing import MatLike # type: ignore
from dotenv import load_dotenv
from PIL import Image
from sora_sdk import Sora, SoraSignalingErrorCode, SoraVideoSource
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(
:param video_fps: ビデオのフレームレート
:param video_fourcc: ビデオの FOURCC コード
"""
self.mp_face_detection = mp.solutions.face_detection
self.mp_face_detection = mp.solutions.face_detection # type: ignore

self._sora = Sora(openh264=None)
self._video_source: SoraVideoSource = self._sora.create_video_source()
Expand Down Expand Up @@ -192,7 +192,10 @@ def run(self) -> None:
self._video_capture.release()

def run_one_frame(
self, face_detection: mp.solutions.face_detection.FaceDetection, angle: int, frame: MatLike
self,
face_detection: mp.solutions.face_detection.FaceDetection, # type: ignore
angle: int,
frame: MatLike, # type: ignore
) -> int:
"""
1フレームの処理を行います。
Expand Down Expand Up @@ -283,7 +286,7 @@ def hideface_sender() -> None:
video_fps = int(os.getenv("SORA_VIDEO_FPS", "30"))
video_fourcc = os.getenv("SORA_VIDEO_FOURCC", "MJPG")

camera_id = int(os.getenv("SORA_CAMERA_ID", "0"))
camera_id = int(os.getenv("SORA_CAMERA_ID", "1"))

streamer = LogoStreamer(
signaling_urls=signaling_urls,
Expand Down
Loading

0 comments on commit 674eddf

Please sign in to comment.