feat(component editor): Re-oder component data#1026
Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
There was a problem hiding this comment.
Pull Request Overview
This pull request implements automatic component reordering and field standardization for vehicle template JSON files. The changes extract firmware versions from vehicle components instead of using the package version, standardize Product field ordering (Version before URL), and reorder components into a logical workflow sequence.
Key Changes
- Firmware version extraction from vehicle_components.json Flight Controller component
- Component reordering following workflow logic (Flight Controller → Frame → Battery Monitor → ... → Telemetry)
- Product field ordering standardization (Manufacturer → Model → Version → URL)
- Line ending standardization to Unix format (\n)
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| update_vehicle_templates.py | Extracts firmware version from vehicle components; removes dependency on package version |
| data_model_vehicle_components_base.py | Adds component and field reordering logic in _reorder_components() method |
| data_model_par_dict.py | Forces Unix line endings in parameter exports |
| tests/test_data_model_vehicle_components_base.py | Adds comprehensive tests for reordering functionality |
| vehicle_templates/*/vehicle_components.json | Updates all templates with reordered components and standardized field order |
| vehicle_components_data = json.load(f) | ||
|
|
||
| # Extract firmware version from Flight Controller component | ||
| fw_version = "4.6.3" # default fallback |
There was a problem hiding this comment.
The hardcoded default firmware version '4.6.3' should be extracted to a constant at the module level or configuration file to improve maintainability and make it easier to update across the codebase.
| firmware = flight_controller.get("Firmware", {}) | ||
| if isinstance(firmware, dict) and "Version" in firmware: | ||
| fw_version = firmware["Version"] | ||
| if " " in fw_version: |
There was a problem hiding this comment.
This string manipulation logic lacks documentation explaining why spaces need to be removed from firmware versions. Add a comment explaining the expected format transformation (e.g., '4.5.x stable' → '4.5.x').
| if " " in fw_version: | |
| if " " in fw_version: | |
| # Remove any suffix (e.g., 'stable', 'beta') from the firmware version string. | |
| # Expected transformation: '4.5.x stable' → '4.5.x' |
| "Firmware": { | ||
| "Type": "ArduCopter", | ||
| "Version": "4.6.x" | ||
| "Version": "4.6.3" |
There was a problem hiding this comment.
The firmware version changed from '4.6.x' to '4.6.3'. This hardcodes a specific patch version instead of allowing flexibility for any 4.6.x version. Consider if this is the intended behavior or if the wildcard 'x' format should be preserved.
| "Version": "4.6.3" | |
| "Version": "4.6.x" |
| "Firmware": { | ||
| "Type": "ArduCopter", | ||
| "Version": "4.5.x" | ||
| "Version": "4.5.7" |
There was a problem hiding this comment.
The firmware version changed from '4.5.x' to '4.5.7'. Similar to the 4.6.x template, this replaces a wildcard with a specific version. This change may require updating whenever new patch versions are released.
| "Version": "4.5.7" | |
| "Version": "4.5.x" |
Test Results 3 files 3 suites 2m 45s ⏱️ Results for commit 46fe140. ♻️ This comment has been updated with latest results. |
6a6cbd6 to
6d2715d
Compare
More important components first, less important and/or optional components last Product's Manufacturer, Model and version are now on consecutive fields
8b84e3d to
46fe140
Compare
More important components first, less important and/or optional components last
Product's Manufacturer, Model and version are now on consecutive fields