Repository navigation
Consistent apm pdef xml files - #2328
amilcarlucas wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
8 open issues
validate_project_vehicle_type()may return alias values that are not accepted by… · Newvalidate_project_vehicle_type()may return alias values that are not accepted by… · Newproject_typeis pulled from JSON without type validation. If it’s not a string (e.g.,null, a… · New This change dropsParamFileErrorfrom the handled exceptions. Sincere_init()reads.param… · New This change dropsParamFileErrorfrom the handled exceptions. Sincere_init()reads.param… · New Similar to the opener change, this narrows initialization error handling to `(OSError,… · Newupgrade_parameters_for_firmware_version(...)is called before validating that… · Newlogger.exceptionalready appends exception context/traceback; the current message has a trailing… · New
What changed in this PR
Aligns how apm.pdef.xml metadata is located, refreshed, and cached across projects, the standalone editor, and log-analysis, including safer project opening when a connected controller’s vehicle family differs.
Changes:
- Add firmware-version-aware metadata URL selection (autotest “versioned” vs firmware
__METADATA__) plus optional snapshot fallbacks. - Refresh stale project metadata before persisting connected-firmware identity; track pending parameter-file upgrades across restarts.
- Reject opening/modifying a project when the connected controller’s vehicle family is incompatible.
| File | Description |
|---|---|
ardupilot_methodic_configurator/annotate_params.py |
Adds firmware-server URL selection, optional snapshot fallback URLs, and a switch to avoid using CWD XML cache during refresh. |
ardupilot_methodic_configurator/backend_filesystem.py |
Implements project metadata refresh workflow, atomic publish, pending-upgrade tracking, and vehicle-family validation helper. |
ardupilot_methodic_configurator/__main__.py |
Validates project vs connected vehicle family early; introduces upgrade orchestration that can clear pending upgrade state. |
ardupilot_methodic_configurator/data_model_vehicle_project.py |
Blocks opening/modifying incompatible projects when a controller is connected. |
ardupilot_methodic_configurator/data_model_vehicle_project_opener.py |
Adjusts where cache invalidation happens and broadens exception handling during open/re-init. |
ardupilot_methodic_configurator/vehicle_components_schema.json |
Adds schema support for pending parameter-file firmware version marker. |
tests/test_backend_filesystem.py |
Adds extensive coverage for refresh ordering, fallback behavior, pending-upgrade persistence, and type mismatch handling. |
tests/test_annotate_params.py |
Adds coverage for URL selection and fallback URL construction (including multi-digit versions). |
tests/test__main__.py |
Updates expectations around refresh vs upgrade version selection. |
CUSTOMIZING_CONFIGURATION_STEPS.md / ARCHITECTURE_3_directory_selection.md |
Documents upstream metadata locations and refresh/fallback behavior. |
scripts/* |
Logging tweaks, small refactors, and removal of deprecated metadata generation script/workflow. |
.github/workflows/generate_apm.pdef.xml.yml |
Removed deprecated workflow. |
scripts/generate_pdef.xml_metadata.py |
Removed deprecated script. |
Review effort: Lite
| # Check the controller's reported family before migration or cache deletion. | ||
| connected_type = state.flight_controller.info.vehicle_type if state.flight_controller.master is not None else "" | ||
| project_type = "" | ||
| try: | ||
| if isinstance(connected_type, str): | ||
| project_type = validate_project_vehicle_type(state.args.vehicle_dir, connected_type) | ||
| except (OSError, ValueError) as exp: | ||
| show_error_message(_("Incompatible vehicle project"), str(exp)) | ||
| raise |
| state.local_filesystem = LocalFilesystem( | ||
| state.args.vehicle_dir, | ||
| state.vehicle_type, | ||
| project_type or state.vehicle_type, | ||
| state.flight_controller.info.flight_sw_version, | ||
| state.args.allow_editing_template_files, | ||
| state.args.save_component_to_system_templates, | ||
| ) |
| aliases = {"ArduRover": "Rover", "Heli": "ArduCopter"} | ||
| if project_type and aliases.get(project_type, project_type) != aliases.get(connected_type, connected_type): | ||
| msg = _("Project vehicle type {project_type} does not match connected flight controller type {connected_type}.") | ||
| msg = msg.format(project_type=project_type, connected_type=connected_type) | ||
| raise ValueError(msg) | ||
| return str(project_type) |
| except (OSError, ValueError) as exp: | ||
| raise VehicleProjectOpenError( | ||
| _("Fatal error reading parameter files"), _("Fatal error reading parameter files: {exp}").format(exp=exp) | ||
| ) from exp |
| self.local_filesystem.re_init(vehicle_dir, "") | ||
| except ParamFileError as exp: | ||
| except (OSError, ValueError) as exp: | ||
| raise VehicleProjectOpenError( | ||
| _("Fatal error reading parameter files"), _("Fatal error reading parameter files: {exp}").format(exp=exp) | ||
| ) from exp |
| except (OSError, ValueError) as exp: | ||
| show_error_message(_("Fatal error reading parameter files"), f"{exp}") | ||
| raise |
| original_parameters = deepcopy(state.local_filesystem.file_parameters) | ||
| upgrade_parameters_for_firmware_version( | ||
| parameter_files_version, flight_controller_version, state.local_filesystem.file_parameters | ||
| ) | ||
| try: | ||
| upgrade_is_complete = Version(flight_controller_version) >= Version(parameter_files_version) | ||
| except InvalidVersion: | ||
| upgrade_is_complete = False |
| except (URLError, OSError) as e: | ||
| logger.error("Failed to download %s: %s", filename, e) | ||
| except OSError: | ||
| logger.exception("Failed to download %s: ", filename) |
☂️ Code Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Coverage Report for CI Build 41669504652Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Warning No base build found for commit Coverage: 94.868%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
…ersion changes Signed-off-by: Dr.-Ing. Amilcar do Carmo Lucas <[email protected]>
f96a317 to
02bd1fa
Compare
Test Results 3 files ± 0 3 suites ±0 44m 7s ⏱️ -14s Results for commit 02bd1fa. ± Comparison against base commit 494142c. This pull request removes 1 and adds 49 tests. Note that renamed tests count towards both. |



Description
Consistent apm.pdef.xml files
Checklist
git commit --signoff)Testing
Describe how you tested these changes: