Separate into base, templates, import and validation#547
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the vehicle components handling by separating the logic into base, templates, import, and validation modules. Key changes include enhancing schema data extraction (with new helper methods), introducing a new data model for components to improve testability and JSON structure consistency, and updating various protocols and validation rules for FC parameters.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| update_vehicle_templates.py | Updated call to ComponentDataModel with datatypes from get_all_value_datatypes. |
| tests/test_backend_filesystem_vehicle_components.py | Added comprehensive tests for schema data extraction and type mapping. |
| ardupilot_methodic_configurator/data_model_vehicle_components_templates.py | Introduced a separate template interface with data operations. |
| ardupilot_methodic_configurator/data_model_vehicle_components_import.py | Enhanced FC parameters processing with improved validation and mapping. |
| ardupilot_methodic_configurator/data_model_vehicle_components_base.py | Created base data model with updated JSON structure and type-safe casting. |
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Added methods for recursive extraction of Python datatypes from the vehicle components JSON schema. |
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
Test Results 2 files ± 0 2 suites ±0 1m 29s ⏱️ +9s Results for commit 44d7997. ± Comparison against base commit 40c29ad. This pull request removes 62 and adds 258 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
67999d5 to
9775209
Compare
…s, import and validation This makes it simpler to test and keeps the linters happier Make the GNSS protocol depend on the GNSS connection type Restrict the RC receiver, telemetry and battery protocols depending on the selected FC connection type Improve and simplify the data validation code Update protocol choices when the type changes and is written. The cell voltage now changes when chemistry changes The TOW limits are checked against each other Validate the dict constants used to validate the data Re-use common fixatures to prevent code duplication
9775209 to
44d7997
Compare
This makes it simpler to test and keeps the linters happier
Make the GNSS protocol depend on the GNSS connection type Restrict the RC receiver, telemetry and battery protocols depending on the selected FC connection type Improve and simplify the data validation code
Update protocol choices when the type changes and is written. The cell voltage now changes when chemistry changes The TOW limits are checked against each other.
This pull request introduces significant updates to the Ardupilot Methodic Configurator, focusing on schema data extraction and a new data model for vehicle components. Key changes include adding methods for extracting and mapping schema-defined data types, implementing a structured data model for component operations, and enhancing JSON format versioning and validation logic.
Schema Data Extraction Enhancements:
get_all_value_datatypesmethod inardupilot_methodic_configurator/backend_filesystem_vehicle_components.pyto extract and map all schema-defined data types into a nested dictionary. This includes recursive handling of schema references andallOfconstructs._extract_datatypes_from_component,_extract_datatypes_from_property, and_json_type_to_python_typeto support recursive traversal and type conversion for JSON schemas.New Data Model for Components:
ComponentDataModelBaseclass inardupilot_methodic_configurator/data_model_vehicle_components_base.pyto separate data operations from UI logic, improving testability.get_component_value) and setting (set_component_value) component values with type-safe casting based on schema-defined data types.These changes enhance the configurator's robustness by enabling schema-driven data validation and ensuring backward compatibility with older JSON formats.