Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests: Small updates & triggering in every PR. #146

Merged
merged 8 commits into from
Dec 10, 2024
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
6 changes: 5 additions & 1 deletion .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
description: 'Testbed to run the tests on. Default: oak4-pro'
required: true
default: 'oak4-pro'
depthai-version:
description: 'Version of depthai to install. Default: alpha6'
required: true
default: '3.0.0a6'

jobs:
HIL-test:
Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:

- name: Run Test
run: |
CMD="hil --testbed ${{ github.event.inputs.testbed }} --reservation-name 'depthai_nodes_ml_team' --commands 'cd /home/hil/depthai-nodes' 'git checkout main' 'git pull' 'git checkout ${{ github.event.inputs.branch }}' 'git pull' 'source venv/bin/activate' 'cd tests/end_to_end' 'source <(python setup_camera_ips.py)' 'export HUBAI_TEAM_ID=${{ secrets.HUBAI_TEAM_ID }}' 'export HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }}' 'python main.py ${{ github.event.inputs.additional-parameter }}' 'deactivate'"
CMD="hil --testbed ${{ github.event.inputs.testbed }} --wait --reservation-name 'depthai_nodes_ml_team' --commands 'cd /home/hil/depthai-nodes' 'git checkout main' 'git pull' 'git checkout ${{ github.event.inputs.branch }}' 'git pull' 'source venv/bin/activate' 'pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==${{ github.event.inputs.depthai-version }}' 'cd tests/end_to_end' 'source <(python setup_camera_ips.py)' 'export HUBAI_TEAM_ID=${{ secrets.HUBAI_TEAM_ID }}' 'export HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }}' 'python main.py ${{ github.event.inputs.additional-parameter }}' 'deactivate'"
eval $CMD

- name: Stop WireGuard
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ on:
description: 'Testbed to run the tests on. Default: oak4-s'
required: true
default: 'oak4-s'
depthai-version:
description: 'Version of depthai to install. Default: alpha6'
required: true
default: '3.0.0a6'
pull_request:
branches:
- main
paths:
- 'depthai_nodes/**'
- 'tests/integration_tests/**'
- .github/workflows/integration_tests.yaml

jobs:
Integration-test:
Expand Down Expand Up @@ -54,7 +65,11 @@ jobs:

- name: Run Test
run: |
CMD="hil --testbed ${{ github.event.inputs.testbed }} --reservation-name 'depthai_nodes_ml_team' --commands 'cd /home/hil/depthai-nodes' 'git checkout main' 'git pull' 'git checkout ${{ github.event.inputs.branch }}' 'git pull' 'source venv/bin/activate' 'cd tests/integration_tests' 'export B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }}' 'export B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }}' 'python main.py ${{ github.event.inputs.additional-parameter }}' 'deactivate'"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
CMD="hil --testbed ${{ github.event.inputs.testbed }} --wait --reservation-name 'depthai_nodes_ml_team' --commands 'cd /home/hil/depthai-nodes' 'git checkout main' 'git pull' 'git checkout ${{ github.event.inputs.branch }}' 'git pull' 'source venv/bin/activate' 'pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==${{ github.event.inputs.depthai-version }}' 'cd tests/integration_tests' 'export B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }}' 'export B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }}' 'python main.py ${{ github.event.inputs.additional-parameter }}' 'deactivate'"
else
CMD="hil --testbed oak4-s --wait --reservation-name 'depthai_nodes_ml_team' --commands 'cd /home/hil/depthai-nodes' 'git checkout main' 'git pull' 'git checkout ${{ github.head_ref }}' 'git pull' 'source venv/bin/activate' 'pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==3.0.0a6' 'cd tests/integration_tests' 'export B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }}' 'export B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }}' 'python main.py -all --download' 'deactivate'"
fi
eval $CMD

- name: Stop WireGuard
Expand Down
3 changes: 2 additions & 1 deletion depthai_nodes/ml/parsers/image_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def run(self):
is_bgr=self.output_is_bgr,
)
image_message.setTimestamp(output.getTimestamp())
image_message.transformation = output.getTransformation()
if output.getTransformation():
image_message.setTransformation(output.getTransformation())

self.out.send(image_message)
14 changes: 8 additions & 6 deletions tests/integration_tests/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ def load_tensors(model: str, parser: str) -> dai.NNData:

# Get the model from the HubAI
try:
model_description = dai.NNModelDescription(
model=model_slug, platform=device_platform
)
model_description = dai.NNModelDescription(model=model_slug, platform="RVC2")
archive_path = dai.getModelFromZoo(model_description)
except Exception as e:
print(f"Error: {e}")
exit(7)
except Exception:
try:
model_description = dai.NNModelDescription(model=model_slug, platform="RVC4")
archive_path = dai.getModelFromZoo(model_description)
except Exception as e:
print(f"Error: {e}")
exit(7)

try:
nn_archive = dai.NNArchive(archive_path)
Expand Down
31 changes: 27 additions & 4 deletions tests/integration_tests/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from typing import List

import depthai as dai
import pytest


Expand All @@ -14,10 +15,32 @@ def models(request):
def get_parametrized_values(models: List[str], parsers: List[str]) -> List[List[str]]:
test_cases = []

devices = dai.Device.getAllConnectedDevices()
if not devices:
pytest.skip("Couldn't find any connected devices.")

devices = [
("RVC2" if "MYRIAD" in device.platform.name else "RVC4", device.getMxId())
for device in devices
]

unique_devices = set()
devices = [
item
for item in devices
if item[0] not in unique_devices and not unique_devices.add(item[0])
]

if models:
models = ast.literal_eval(models)
parsers = ast.literal_eval(parsers)
test_cases.extend([(model, parsers[i]) for i, model in enumerate(models)])
test_cases.extend(
[
(model, parsers[i], platform, mxid)
for i, model in enumerate(models)
for (platform, mxid) in devices
]
)

return test_cases

Expand All @@ -26,18 +49,18 @@ def pytest_generate_tests(metafunc):
models = metafunc.config.getoption("models")
parsers = metafunc.config.getoption("parsers")
params = get_parametrized_values(models, parsers)
metafunc.parametrize("models, parsers", params)
metafunc.parametrize("models, parsers, platform, mxid", params)


def test_parser(models, parsers):
def test_parser(models, parsers, platform, mxid):
time.sleep(5) # device needs some time to finish previous pipeline
if not models:
raise ValueError("You have to pass models")

try:
if models:
subprocess.run(
f"python manual.py -m {models}",
f"python manual.py -m {models} -ip {mxid}",
shell=True,
check=True,
timeout=90,
Expand Down
Loading