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

Configured codecov #81

Merged
merged 7 commits into from
Sep 25, 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
46 changes: 9 additions & 37 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,48 +128,20 @@ jobs:
token_format: access_token

- name: Run pytest
uses: pavelzw/pytest-action@v2
env:
LUXONISML_BUCKET: luxonis-test-bucket
PYTORCH_MPS_HIGH_WATERMARK_RATIO: 0.0
with:
emoji: false
custom-arguments: --junit-xml pytest.xml --cov luxonis_train --cov-report xml
run: pytest --cov --junitxml=junit.xml -o junit_family=legacy

- name: Create Test Report
uses: EnricoMi/publish-unit-test-result-action@v2
- name: Upload test results to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/test-results-action@v1
with:
files: pytest.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

- name: Generate coverage badge
uses: tj-actions/coverage-badge-py@v2
- name: Upload coverage results to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
output: media/coverage_badge.svg

- name: Generate coverage report
uses: orgoro/[email protected]
if: matrix.os == 'ubuntu-latest'
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.9
thresholdNew: 0.8

- name: Commit coverage badge
if: matrix.os == 'ubuntu-latest'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git diff --quiet media/coverage_badge.svg || {
git add media/coverage_badge.svg
git commit -m "[Automated] Updated coverage badge"
}

- name: Push changes
uses: ad-m/github-push-action@master
if: matrix.os == 'ubuntu-latest'
with:
branch: ${{ github.head_ref }}

token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![CI](https://github.com/luxonis/luxonis-train/actions/workflows/ci.yaml/badge.svg)
![Docs](https://github.com/luxonis/luxonis-train/actions/workflows/docs.yaml/badge.svg)
[![Coverage](media/coverage_badge.svg)](https://github.com/luxonis/luxonis-train/actions)
[![codecov](https://codecov.io/gh/luxonis/luxonis-train/graph/badge.svg?token=647MTHBYD5)](https://codecov.io/gh/luxonis/luxonis-train)

Luxonis training framework (`luxonis-train`) is intended for training deep learning models that can run fast on OAK products.

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def CIFAR10_subset_generator():

@pytest.fixture
def config(train_overfit: bool) -> dict[str, Any]:
if train_overfit:
if train_overfit: # pragma: no cover
epochs = 100
else:
epochs = 1
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/multi_input_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def input_shapes(self):
"pointcloud": torch.Size([1000, 3]),
}

def __getitem__(self, _):
def __getitem__(self, _): # pragma: no cover
# Fake data
left = torch.rand(3, 224, 224, dtype=torch.float32)
right = torch.rand(3, 224, 224, dtype=torch.float32)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def train_and_test(
):
model = LuxonisModel(config, opts)
model.train()
results = model.test(view="val")
if train_overfit:
if train_overfit: # pragma: no cover
results = model.test(view="val")
for name, value in results.items():
if "/map_50" in name or "/kpt_map_medium" in name:
assert value > 0.8, f"{name} = {value} (expected > 0.8)"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def train_and_test(
):
model = LuxonisModel(config, opts)
model.train()
results = model.test(view="val")
if train_overfit:
if train_overfit: # pragma: no cover
results = model.test(view="val")
for name, value in results.items():
if "metric" in name:
assert value > 0.8, f"{name} = {value} (expected > 0.8)"
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/test_base_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_invalid(packet: Packet[Tensor]):
node.wrap({"inp": torch.rand(3, 224, 224)})


def tets_in_sizes():
def test_in_sizes():
node = DummyNode(
input_shapes=[{"features": [Size((3, 224, 224)) for _ in range(3)]}]
)
Expand Down
55 changes: 29 additions & 26 deletions tests/unittests/test_utils/test_boxutils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Literal

import pytest
import torch

Expand All @@ -13,7 +15,10 @@


def generate_random_bboxes(
n_bboxes: int, max_width: int, max_height: int, format: str = "xyxy"
n_bboxes: int,
max_width: int,
max_height: int,
format: Literal["xyxy", "xywh", "cxcywh"],
):
x1y1 = torch.rand(n_bboxes, 2) * torch.tensor(
[max_width - 1, max_height - 1]
Expand All @@ -33,10 +38,6 @@ def generate_random_bboxes(
elif format == "cxcywh":
cxcy = x1y1 + wh / 2
bboxes = torch.cat((cxcy, wh), dim=1)
else:
raise ValueError(
"Unsupported format. Choose from 'xyxy', 'xywh', 'cxcywh'."
)

return bboxes

Expand All @@ -62,27 +63,29 @@ def test_bbox2dist():


@pytest.mark.parametrize("iou_type", ["none", "giou", "diou", "ciou", "siou"])
def test_bbox_iou(iou_type: IoUType):
for format in ["xyxy", "cxcywh", "xywh"]:
bbox1 = generate_random_bboxes(5, 640, 640, format)
if iou_type == "siou":
bbox2 = generate_random_bboxes(5, 640, 640, format)
else:
bbox2 = generate_random_bboxes(8, 640, 640, format)

iou = bbox_iou(
bbox1,
bbox2,
bbox_format=format, # type: ignore
iou_type=iou_type,
)

assert iou.shape == (bbox1.shape[0], bbox2.shape[0])
if iou_type == "none":
min = 0
else:
min = -1.5
assert iou.min() >= min and iou.max() <= 1
@pytest.mark.parametrize("format", ["xyxy", "xywh", "cxcywh"])
def test_bbox_iou(
iou_type: IoUType, format: Literal["xyxy", "xywh", "cxcywh"]
):
bbox1 = generate_random_bboxes(5, 640, 640, format)
if iou_type == "siou":
bbox2 = generate_random_bboxes(5, 640, 640, format)
else:
bbox2 = generate_random_bboxes(8, 640, 640, format)

iou = bbox_iou(
bbox1,
bbox2,
bbox_format=format, # type: ignore
iou_type=iou_type,
)

assert iou.shape == (bbox1.shape[0], bbox2.shape[0])
if iou_type == "none":
min = 0
else:
min = -1.5
assert iou.min() >= min and iou.max() <= 1

if iou_type == "none":
with pytest.raises(ValueError):
Expand Down