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
13 changes: 10 additions & 3 deletions tinyml-modelmaker/tests/test_config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pytest
import yaml

from tinyml_modelmaker.ai_modules.audio import training as audio_training
from tinyml_modelmaker.ai_modules.audio import constants as audio_constants
from tinyml_modelmaker.ai_modules.timeseries import training, constants


Expand Down Expand Up @@ -38,8 +40,12 @@ def _find_example_configs():

EXAMPLE_CONFIGS = _find_example_configs()

# Known valid task types (timeseries + vision)
KNOWN_TASK_TYPES = set(constants.TASK_TYPE_TO_CATEGORY.keys()) | {"image_classification"}
# Known valid task types (timeseries + vision + audio)
KNOWN_TASK_TYPES = (
set(constants.TASK_TYPE_TO_CATEGORY.keys())
| set(audio_constants.TASK_TYPES)
| {"image_classification"}
)

# Required top-level keys in every config
REQUIRED_SECTIONS = {"common", "training"}
Expand Down Expand Up @@ -150,7 +156,8 @@ def test_model_name_exists_in_registry(self, config_path):
if task_type == "image_classification":
pytest.skip("Vision model registry not tested here")

desc = training.get_model_description(model_name)
registry = audio_training if task_type in audio_constants.TASK_TYPES else training
desc = registry.get_model_description(model_name)
assert desc is not None, (
f"Config references model '{model_name}' which is not in the registry"
)
5 changes: 3 additions & 2 deletions tinyml-modelmaker/tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def test_anomaly_returns_classes(self):
== ts_constants.DATA_DIR_CLASSES
)

def test_unknown_category_returns_classes(self):
assert ts_constants.get_default_data_dir_for_task("something_else") == ts_constants.DATA_DIR_CLASSES
def test_unknown_category_raises(self):
with pytest.raises(ValueError, match="Unsupported task_category"):
ts_constants.get_default_data_dir_for_task("something_else")

def test_vision_returns_classes(self):
# Vision module always returns 'classes'
Expand Down
14 changes: 7 additions & 7 deletions tinyml-modelmaker/tests/test_cross_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class TestQuantizationFlags:
def test_float_mode_no_normalize(self, task_category):
"""Quantization=0 (float) should set skip_normalize=False, output_int=False."""
skip, output = constants.get_skip_normalize_and_output_int(
task_category, quantization=0, partial_quantization=False
task_category, quantization=0, auto_quantization=False
)
assert skip is False
assert output is False
Expand All @@ -364,7 +364,7 @@ def test_classification_quant_sets_output_int(self):
"""Classification with quantization should set output_int=True."""
skip, output = constants.get_skip_normalize_and_output_int(
constants.TASK_CATEGORY_TS_CLASSIFICATION,
quantization=1, partial_quantization=False,
quantization=1, auto_quantization=False,
)
assert skip is True
assert output is True
Expand All @@ -373,7 +373,7 @@ def test_regression_quant_no_output_int(self):
"""Regression with quantization should set output_int=False."""
skip, output = constants.get_skip_normalize_and_output_int(
constants.TASK_CATEGORY_TS_REGRESSION,
quantization=1, partial_quantization=False,
quantization=1, auto_quantization=False,
)
assert skip is True
assert output is False
Expand All @@ -382,16 +382,16 @@ def test_forecasting_quant_no_output_int(self):
"""Forecasting with quantization should set output_int=False."""
skip, output = constants.get_skip_normalize_and_output_int(
constants.TASK_CATEGORY_TS_FORECASTING,
quantization=1, partial_quantization=False,
quantization=1, auto_quantization=False,
)
assert skip is True
assert output is False

def test_partial_quant_regression_override(self):
"""Partial quantization for regression should set skip_normalize=False."""
def test_auto_quant_regression_override(self):
"""Auto quantization for regression should set skip_normalize=False."""
skip, output = constants.get_skip_normalize_and_output_int(
constants.TASK_CATEGORY_TS_REGRESSION,
quantization=1, partial_quantization=True,
quantization=1, auto_quantization=True,
)
assert skip is False
assert output is False
2 changes: 1 addition & 1 deletion tinyml-modelmaker/tests/test_dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_split_factor_too_large(self, tmp_path):
fl = tmp_path / "file_list.txt"
fl.write_text("a.csv\nb.csv\n")
split_files = (str(tmp_path / "train.txt"), str(tmp_path / "val.txt"))
with pytest.raises(ValueError, match="less than 1"):
with pytest.raises(ValueError, match=r"range \(0\.0, 1\.0\)"):
dataset_utils.create_inter_file_split(str(fl), split_files, 1.5)

def test_split_factor_list_sum_too_large(self, tmp_path):
Expand Down
Loading