Skip to content

Consistent apm pdef xml files - #2328

Open
amilcarlucas wants to merge 1 commit into
masterfrom
Consistent_apm_pdef_xml_files
Open

amilcarlucas wants to merge 1 commit into
masterfrom
Consistent_apm_pdef_xml_files

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

Description

Consistent apm.pdef.xml files

Checklist

  • Run pre-commit checks locally
  • Verified by a human programmer
  • All commits are signed off (use git commit --signoff)
  • Code follows our coding standards
  • Documentation updated if needed
  • No breaking changes or properly documented

Testing

Describe how you tested these changes:

  • Unit tests pass
  • Integration tests pass
  • Manual testing performed
  • Tested on flight controller hardware

Copilot AI balanced review requested due to automatic review settings November 3, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
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

Comment on lines +434 to +442
# 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
Comment on lines 452 to 458
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,
)
Comment on lines +84 to +89
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
Comment on lines 154 to 158
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
Comment on lines +459 to 461
except (OSError, ValueError) as exp:
show_error_message(_("Fatal error reading parameter files"), f"{exp}")
raise
Comment on lines +829 to +836
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)
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
30026 28475 95% 89% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 02bd1fa by action🐍

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 41669504652

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit 452be43 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 94.868%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 30026
Covered Lines: 28485
Line Coverage: 94.87%
Relevant Branches: 9050
Covered Branches: 8078
Branch Coverage: 89.26%
Branches in Coverage %: No
Coverage Strength: 2.83 hits per line

💛 - Coveralls

…ersion changes

Signed-off-by: Dr.-Ing. Amilcar do Carmo Lucas <[email protected]>
@amilcarlucas
amilcarlucas force-pushed the Consistent_apm_pdef_xml_files branch from f96a317 to 02bd1fa Compare November 4, 2026 08:02
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

     3 files  ±  0       3 suites  ±0   44m 7s ⏱️ -14s
 9 264 tests + 48   9 259 ✅ + 48   5 💤 ±0  0 ❌ ±0 
27 660 runs  +144  27 625 ✅ +144  35 💤 ±0  0 ❌ ±0 

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.
tests.test__main__.TestEditorBackupAndMainOrchestration ‑ test_main_saves_fc_version_for_directly_opened_project
tests.test__main__.TestEditorBackupAndMainOrchestration ‑ test_main_uses_original_project_version_after_metadata_refresh
tests.test_backend_filesystem ‑ test_clearing_absent_pending_upgrade_is_a_noop
tests.test_backend_filesystem ‑ test_connected_controller_rejects_other_vehicle_family_before_project_changes[open_last_vehicle_directory]
tests.test_backend_filesystem ‑ test_connected_controller_rejects_other_vehicle_family_before_project_changes[open_vehicle_directory]
tests.test_backend_filesystem ‑ test_copter_and_heli_share_a_firmware_family[ArduCopter]
tests.test_backend_filesystem ‑ test_copter_and_heli_share_a_firmware_family[Heli]
tests.test_backend_filesystem ‑ test_direct_start_rejects_other_vehicle_family_before_migration
tests.test_backend_filesystem ‑ test_direct_start_uses_compatible_project_type[False]
tests.test_backend_filesystem ‑ test_direct_start_uses_compatible_project_type[True]
tests.test_backend_filesystem ‑ test_download_is_staged_on_the_same_filesystem_as_the_project
…

This branch has not been deployed

No deployments
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.

3 participants