From 8d8d3006143f8b15ab11896033cebcc2cf172177 Mon Sep 17 00:00:00 2001 From: M Platypus Date: Tue, 28 Jul 2026 21:14:45 -0400 Subject: [PATCH 1/2] test: fix stale/wrong assertions unrelated to production code - test_config_validation.py: KNOWN_TASK_TYPES and the model-registry check only covered timeseries+vision, so every audio modelzoo example (task_type='audio_classification', e.g. DSCNN_NPU) looked invalid. Include the audio module's task types and route audio configs to its own model registry. - test_constants.py: get_default_data_dir_for_task() was intentionally changed to raise ValueError on unknown categories in 90ce979 (CodeRabbit fix), but the test still asserted the old silent DATA_DIR_CLASSES fallback. Update the test to match. - test_cross_device.py: TestQuantizationFlags called get_skip_normalize_and_output_int(..., partial_quantization=...), but the real parameter is auto_quantization -- a wrong kwarg name, not a real API. Rename calls and the one test that was actually about auto_quantization semantics. - test_dataset_utils.py: test_split_factor_too_large matched a stale error-message regex ("less than 1") against the current message ("must be in the range (0.0, 1.0)"); behavior was already correct. Confirmed via git stash that all of the above failed identically before the unrelated ConfigDict deep-merge fix, i.e. pre-existing and unrelated to it. One real gap found and left open per user decision: F28E12 is listed in TARGET_DEVICES but has no entry in _DEVICE_PROFILES, so test_cross_device.py::TestCompilationProfileCorrectness still fails for it (5 tests). Needs real hardware values (cross_compiler path, target, target_c_mcpu, has_hard_npu) that aren't safe to guess. Co-Authored-By: Claude Sonnet 5 --- tinyml-modelmaker/tests/test_config_validation.py | 13 ++++++++++--- tinyml-modelmaker/tests/test_constants.py | 5 +++-- tinyml-modelmaker/tests/test_cross_device.py | 14 +++++++------- tinyml-modelmaker/tests/test_dataset_utils.py | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tinyml-modelmaker/tests/test_config_validation.py b/tinyml-modelmaker/tests/test_config_validation.py index 26bcd8a8..bb8dd2e9 100644 --- a/tinyml-modelmaker/tests/test_config_validation.py +++ b/tinyml-modelmaker/tests/test_config_validation.py @@ -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 @@ -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"} @@ -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" ) diff --git a/tinyml-modelmaker/tests/test_constants.py b/tinyml-modelmaker/tests/test_constants.py index 856e8d65..99e0d6b7 100644 --- a/tinyml-modelmaker/tests/test_constants.py +++ b/tinyml-modelmaker/tests/test_constants.py @@ -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' diff --git a/tinyml-modelmaker/tests/test_cross_device.py b/tinyml-modelmaker/tests/test_cross_device.py index 4f4c1d8a..73eceea0 100644 --- a/tinyml-modelmaker/tests/test_cross_device.py +++ b/tinyml-modelmaker/tests/test_cross_device.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tinyml-modelmaker/tests/test_dataset_utils.py b/tinyml-modelmaker/tests/test_dataset_utils.py index e098711d..895c5640 100644 --- a/tinyml-modelmaker/tests/test_dataset_utils.py +++ b/tinyml-modelmaker/tests/test_dataset_utils.py @@ -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): From c5b71d10d390d6148a776e137987b2166914a832 Mon Sep 17 00:00:00 2001 From: M Platypus Date: Wed, 29 Jul 2026 11:15:39 -0400 Subject: [PATCH 2/2] fix(ci): trigger on tinyml-modelzoo changes too tinyml-modelmaker depends on tinyml-modelzoo (pip install -e tinyml-modelzoo in the Install dependencies step), but dependency-only changes to it wouldn't trigger the test suite at all. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/test-modelmaker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-modelmaker.yml b/.github/workflows/test-modelmaker.yml index 7233d670..126ecf47 100644 --- a/.github/workflows/test-modelmaker.yml +++ b/.github/workflows/test-modelmaker.yml @@ -5,11 +5,13 @@ on: branches: [platypus_dev_1.3, main] paths: - 'tinyml-modelmaker/**' + - 'tinyml-modelzoo/**' - '.github/workflows/test-modelmaker.yml' pull_request: branches: [platypus_dev_1.3, main] paths: - 'tinyml-modelmaker/**' + - 'tinyml-modelzoo/**' workflow_dispatch: # manual trigger jobs: