Utility Functions
This page outlines the unit test coverage for the utils.py module, which provides utility functions for configuration management, device detection, and YAML file generation.
Coverage Overview
The following utilities are tested:
detect_device(): Determines available hardware (CUDA, MPS, or CPU)load_config(): Loads and validates configuration from a JSON filecreate_data_yaml(): Generates a standarddata.yamlfor YOLO trainingcreate_quantize_yaml(): Creates aquantize.yamlfile with placeholder values
Function Tests
Device Detection
test_detect_device_cuda: Asserts CUDA is returned when available.test_detect_device_mps: Asserts MPS is returned if CUDA is unavailable.test_detect_device_cpu: Falls back to CPU when neither CUDA nor MPS is available.
Configuration Loading
test_load_config_valid_file: Loads a valid JSON config file and checks its content.test_load_config_file_not_found: RaisesFileNotFoundErrorfor a missing file.test_load_config_invalid_json: RaisesJSONDecodeErrorfor malformed JSON.test_load_config_invalid_distillation_prop: RaisesValueErrorifdistillation_image_propis negative.test_load_config_default_path: Validates fallback behavior using a mocked default path.
YAML File Creation
test_create_data_yaml: Asserts creation and content of a validdata.yamlfile.test_create_quantize_yaml: Confirmsquantize.yamlfile is created in the expected location with placeholder structure.
Summary
These unit tests ensure that utility functions used across the AutoML pipeline behave predictably and handle edge cases gracefully. They support robustness in configuration, hardware compatibility, and file generation workflows.