mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 17:46:41 +00:00
Update test results directory structure and enhance Docker configurations
- Modified `.gitignore` to reflect the new path for test results. - Updated `docker-compose.test.yml` to mount the correct test results directory. - Adjusted `Dockerfile.test` to set the `PYTHONPATH` and ensure test results are saved in the updated location. - Added `boto3` and `netron` to `requirements-test.txt` to support new functionalities. - Updated `pytest.ini` to include the new `pythonpath` for test discovery. These changes streamline the testing process and ensure compatibility with the updated directory structure.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import concurrent.futures
|
||||
import random
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
@@ -11,13 +9,6 @@ import pytest
|
||||
|
||||
from tests.conftest import apply_constants_patch
|
||||
|
||||
if "matplotlib" not in sys.modules:
|
||||
_mpl = types.ModuleType("matplotlib")
|
||||
_plt = types.ModuleType("matplotlib.pyplot")
|
||||
_mpl.pyplot = _plt
|
||||
sys.modules["matplotlib"] = _mpl
|
||||
sys.modules["matplotlib.pyplot"] = _plt
|
||||
|
||||
|
||||
def _patch_augmentation_paths(monkeypatch, base: Path):
|
||||
apply_constants_patch(monkeypatch, base)
|
||||
@@ -44,6 +35,7 @@ def _seed():
|
||||
def test_pt_aug_01_throughput_ten_images_sixty_seconds(
|
||||
tmp_path, monkeypatch, sample_images_labels
|
||||
):
|
||||
# Arrange
|
||||
_patch_augmentation_paths(monkeypatch, tmp_path)
|
||||
_augment_annotation_with_total(monkeypatch)
|
||||
_seed()
|
||||
@@ -59,9 +51,11 @@ def test_pt_aug_01_throughput_ten_images_sixty_seconds(
|
||||
shutil.copy2(p, img_dir / p.name)
|
||||
for p in src_lbl.glob("*.txt"):
|
||||
shutil.copy2(p, lbl_dir / p.name)
|
||||
# Act
|
||||
t0 = time.perf_counter()
|
||||
Augmentator().augment_annotations()
|
||||
elapsed = time.perf_counter() - t0
|
||||
# Assert
|
||||
assert elapsed <= 60.0
|
||||
|
||||
|
||||
@@ -69,6 +63,7 @@ def test_pt_aug_01_throughput_ten_images_sixty_seconds(
|
||||
def test_pt_aug_02_parallel_at_least_one_point_five_x_faster(
|
||||
tmp_path, monkeypatch, sample_images_labels
|
||||
):
|
||||
# Arrange
|
||||
_patch_augmentation_paths(monkeypatch, tmp_path)
|
||||
_augment_annotation_with_total(monkeypatch)
|
||||
_seed()
|
||||
@@ -97,6 +92,7 @@ def test_pt_aug_02_parallel_at_least_one_point_five_x_faster(
|
||||
|
||||
entries = [_E(n) for n in names]
|
||||
|
||||
# Act
|
||||
aug_seq = Augmentator()
|
||||
aug_seq.total_images_to_process = len(entries)
|
||||
t0 = time.perf_counter()
|
||||
@@ -115,4 +111,5 @@ def test_pt_aug_02_parallel_at_least_one_point_five_x_faster(
|
||||
list(ex.map(aug_par.augment_annotation, entries))
|
||||
par_elapsed = time.perf_counter() - t0
|
||||
|
||||
# Assert
|
||||
assert seq_elapsed >= par_elapsed * 1.5
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
from os import path as osp
|
||||
from pathlib import Path
|
||||
|
||||
@@ -10,40 +8,6 @@ import pytest
|
||||
import constants as c_mod
|
||||
|
||||
|
||||
def _stub_train_dependencies():
|
||||
if getattr(_stub_train_dependencies, "_done", False):
|
||||
return
|
||||
|
||||
def add_mod(name):
|
||||
if name in sys.modules:
|
||||
return sys.modules[name]
|
||||
m = types.ModuleType(name)
|
||||
sys.modules[name] = m
|
||||
return m
|
||||
|
||||
ultra = add_mod("ultralytics")
|
||||
|
||||
class YOLO:
|
||||
pass
|
||||
|
||||
ultra.YOLO = YOLO
|
||||
|
||||
def fake_client(*_a, **_k):
|
||||
return types.SimpleNamespace(
|
||||
upload_fileobj=lambda *_a, **_k: None,
|
||||
download_file=lambda *_a, **_k: None,
|
||||
)
|
||||
|
||||
boto = add_mod("boto3")
|
||||
boto.client = fake_client
|
||||
add_mod("netron")
|
||||
add_mod("requests")
|
||||
_stub_train_dependencies._done = True
|
||||
|
||||
|
||||
_stub_train_dependencies()
|
||||
|
||||
|
||||
def _prepare_form_dataset(
|
||||
monkeypatch,
|
||||
tmp_path,
|
||||
@@ -82,6 +46,7 @@ def test_pt_dsf_01_dataset_formation_under_thirty_seconds(
|
||||
fixture_images_dir,
|
||||
fixture_labels_dir,
|
||||
):
|
||||
# Arrange
|
||||
train, today_ds = _prepare_form_dataset(
|
||||
monkeypatch,
|
||||
tmp_path,
|
||||
@@ -91,7 +56,9 @@ def test_pt_dsf_01_dataset_formation_under_thirty_seconds(
|
||||
100,
|
||||
set(),
|
||||
)
|
||||
# Act
|
||||
t0 = time.perf_counter()
|
||||
train.form_dataset()
|
||||
elapsed = time.perf_counter() - t0
|
||||
# Assert
|
||||
assert elapsed <= 30.0
|
||||
|
||||
Reference in New Issue
Block a user