Skip to content

Vehicle Component editor JSON Schema class refactor #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

amilcarlucas
Copy link
Collaborator

No description provided.

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 11:37
Copy link
Contributor

github-actions bot commented Jul 3, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7064 5437 77% 73% 🟢

New Files

File Coverage Status
ardupilot_methodic_configurator/data_model_vehicle_components_display.py 98% 🟢
ardupilot_methodic_configurator/data_model_vehicle_components_json_schema.py 87% 🟢
TOTAL 93% 🟢

Modified Files

File Coverage Status
ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py 88% 🟢
ardupilot_methodic_configurator/data_model_vehicle_components.py 100% 🟢
ardupilot_methodic_configurator/data_model_vehicle_components_base.py 89% 🟢
ardupilot_methodic_configurator/frontend_tkinter_component_editor.py 86% 🟢
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py 80% 🟢
TOTAL 88% 🟢

updated for commit: cb5abd0 by action🐍

Copy link
Contributor

github-actions bot commented Jul 3, 2025

Test Results

    2 files  ± 0      2 suites  ±0   1m 56s ⏱️ +23s
1 421 tests +37  1 414 ✅ +37   7 💤 ±0  0 ❌ ±0 
2 842 runs  +74  2 828 ✅ +74  14 💤 ±0  0 ❌ ±0 

Results for commit cb5abd0. ± Comparison against base commit af95273.

This pull request removes 47 and adds 84 tests. Note that renamed tests count towards both.
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_check_allof_constructs
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_check_direct_properties
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_component_property_description
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_get_all_value_datatypes
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_get_all_value_datatypes_empty_schema
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_get_all_value_datatypes_unknown_types
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_get_component_property_description_exception_handling
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_modify_schema_for_mcu_series
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_modify_schema_for_mcu_series_missing_properties
tests.test_backend_filesystem_vehicle_components.TestVehicleComponents ‑ test_modify_schema_for_mcu_series_no_schema
…
tests.test_data_model_vehicle_components_display.TestEdgeCasesAndErrorHandling ‑ test_system_handles_complex_nested_structures
tests.test_data_model_vehicle_components_display.TestEdgeCasesAndErrorHandling ‑ test_system_handles_empty_components_gracefully
tests.test_data_model_vehicle_components_display.TestEdgeCasesAndErrorHandling ‑ test_system_handles_mixed_data_types_in_components
tests.test_data_model_vehicle_components_display.TestLeafComponentDisplay ‑ test_user_does_not_see_optional_leaf_components_in_simple_mode
tests.test_data_model_vehicle_components_display.TestLeafComponentDisplay ‑ test_user_sees_all_leaf_components_in_normal_mode
tests.test_data_model_vehicle_components_display.TestLeafComponentDisplay ‑ test_user_sees_required_leaf_components_in_simple_mode
tests.test_data_model_vehicle_components_display.TestSimpleModeDisplay ‑ test_user_does_not_see_optional_only_components_in_simple_mode
tests.test_data_model_vehicle_components_display.TestSimpleModeDisplay ‑ test_user_sees_all_components_in_normal_mode
tests.test_data_model_vehicle_components_display.TestSimpleModeDisplay ‑ test_user_sees_nested_components_with_required_fields_in_simple_mode
tests.test_data_model_vehicle_components_display.TestSimpleModeDisplay ‑ test_user_sees_only_required_components_in_simple_mode
…

♻️ This comment has been updated with latest results.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors the vehicle component editor to centralize JSON Schema handling in a new VehicleComponentsJsonSchema class, injects the schema into data models and UI components, and updates tests to use the new schema-based workflows.

  • Extracted datatype and description logic into VehicleComponentsJsonSchema
  • Injected schema into all ComponentDataModel* constructors and UI setup
  • Updated tests to instantiate and mock the new schema class

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

File Description
ardupilot_methodic_configurator/data_model_vehicle_components_json_schema.py Introduces VehicleComponentsJsonSchema to manage schema logic
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py Updates data model creation and UI delegation to use the new schema
tests/ (multiple files) Modifies tests to create and mock VehicleComponentsJsonSchema
Comments suppressed due to low confidence (1)

ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:444

  • The method checks for self.validate_data but no such method is defined on the editor. You should call the actual validation API (e.g., self.data_model.validate_all_data) or implement validate_data on the editor before this check.
        if hasattr(self, "validate_data"):

mcu_series_field.pop("x-is-optional", None)

logging_debug(
_("Modified schema: MCU Series x-is-optional=%s to value=%u"),
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format string uses %u which isn’t supported by Python’s old-style formatting; it should use %d or %s for the boolean/integer value to avoid runtime errors.

Suggested change
_("Modified schema: MCU Series x-is-optional=%s to value=%u"),
_("Modified schema: MCU Series x-is-optional=%s to value=%s"),

Copilot uses AI. Check for mistakes.

@amilcarlucas amilcarlucas force-pushed the schema_refactor branch 3 times, most recently from db0f2bc to 7f4f777 Compare July 3, 2025 19:37
@amilcarlucas amilcarlucas merged commit 78bcf75 into master Jul 3, 2025
22 of 26 checks passed
@amilcarlucas amilcarlucas deleted the schema_refactor branch July 3, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant