Skip to content

fix(projects): retain source-only FC parameters in template imports - #2186

Open
amilcarlucas wants to merge 1 commit into
masterfrom
migration_acceptance
Open

amilcarlucas wants to merge 1 commit into
masterfrom
migration_acceptance

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

Description

Preserve flight-controller settings that are absent from the selected template instead of silently dropping them during project creation.

  • Export unrepresented source parameters to a final numbered import step
  • Scan copied parameter files without loading or mutating the source project
  • Leave template defaults unchanged and omit imported change reasons
  • Allow dedicated FC and bin-log imports to manage their own residual export
  • Remove newly created projects when residual retention fails

Strengthen template-import acceptance coverage:

  • Discover nested templates while pruning migration directories
  • Isolate workflow inputs and require local parameter metadata
  • Assert complete parameter membership, values, comments, and precedence
  • Verify component inference from deliberately incorrect initial values
  • Preserve non-inferable component context
  • Validate regeneration against independent configuration expectations
  • Exercise real manager, component-editor, and parameter-editor workflows
  • Verify preview-only startup and persistence requiring user permission
  • Detect missing inference, saving, rules, context, and source parameters
  • Copy templates before tests that can invalidate cached metadata

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 October 8, 2026 11:57
@amilcarlucas amilcarlucas added the AIReview Request an automated AI review; picked up by the reviewprs sweep label Oct 8, 2026

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.

🟡 Changes recommended

FC residual-export failures can leave incomplete projects, and retention failures receive a misleading copy-error title.

2 open findings
What changed in this PR

Preserves source-only flight-controller parameters during template imports and expands acceptance coverage.

Changes:

  • Exports unrepresented parameters to a final numbered step.
  • Avoids duplicate residual exports in dedicated import workflows.
  • Adds comprehensive import, inference, persistence, and cleanup tests.
File Description
.gitignore Ignores node_modules.
backend_filesystem.py Adds residual parameter export.
data_model_vehicle_project.py Delegates dedicated residual imports.
data_model_vehicle_project_creator.py Integrates retention and cleanup.
tests/​test_data_model_vehicle_project.py Updates workflow expectations.
tests/​test_data_model_vehicle_project_creator.py Tests retention and cleanup.
tests/​template_import_helpers.py Adds independent acceptance-test helpers.
tests/​acceptance_template_import_from_params.py Strengthens end-to-end import coverage.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

settings,
fc_connected=True,
fc_parameters=fc_parameters,
retain_source_parameters=False,
Comment on lines +549 to 555
if not error_msg and settings.use_fc_params and fc_parameters and retain_source_parameters:
self.local_filesystem.retain_unrepresented_fc_parameters(
new_vehicle_dir, fc_parameters, self.next_import_filename
)
except Exception as exc:
shutil_rmtree(new_vehicle_dir, ignore_errors=True)
raise VehicleProjectCreationError(_("Copying template files"), str(exc)) from exc
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
27166 24901 92% 89% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/backend_filesystem.py 92% 🟢
ardupilot_methodic_configurator/data_model_vehicle_project.py 97% 🟢
ardupilot_methodic_configurator/data_model_vehicle_project_creator.py 100% 🟢
TOTAL 96% 🟢

updated for commit: e3adb17 by action🐍

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

     3 files       3 suites   37m 25s ⏱️
 7 017 tests  6 874 ✅  8 💤  4 ❌ 131 🔥
20 932 runs  20 497 ✅ 30 💤 12 ❌ 393 🔥

For more details on these failures and errors, see this check.

Results for commit e3adb17.

♻️ This comment has been updated with latest results.

@AP-Review

AP-Review commented Oct 8, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-10-08)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head a4cfaa8e3f.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/methodicconfigurator/2186/1.html#prMethodicConfigurator-2186

Thanks for this. Retaining source-only FC values is a good change, but CI will not pass as it stands.

The reworked acceptance tests require apm.pdef.xml inside each template (acceptance_template_import_from_params.py:386, template_import_helpers.py:143). That file is gitignored and not tracked for most templates, including empty_4.6.x and ArduPlane/empty_4.7.x, and the new autouse fixture blocks the download that used to provide it. On this head I get 4 failed and 131 errors, the same as CI showed for 9ea2d39. Could you commit or seed the XML the tests need, or skip clearly when it is absent?

In the generic template path, retain_unrepresented_fc_parameters (backend_filesystem.py:837) exports every FC value not in a template step, including values still at their default. With a full FC download into empty_4.6.x the final step had 732 entries, 731 of them defaults, including INS_ACCOFFS_* and INS_GYROFFS_*. Because the editor preselects differing values for upload, a calibration made at an earlier step could be offered for reset to 0. Filtering against the FC defaults, as _complete_imported_vehicle_project_creation already does, would avoid this.

Minor: a retention failure is reported as 'Copying template files' instead of 'Parameter import' (data_model_vehicle_project_creator.py:550), as Copilot also noted. Cleanup itself works.

Copilot's point about missing cleanup in the FC workflow is real, but it predates this PR; it would be good to fix separately.

Preserve flight-controller settings that are absent from the selected
template instead of silently dropping them during project creation.

- Export unrepresented source parameters to a final numbered import step
- Scan copied parameter files without loading or mutating the source project
- Leave template defaults unchanged and omit imported change reasons
- Allow dedicated FC and bin-log imports to manage their own residual export
- Remove newly created projects when residual retention fails

Strengthen template-import acceptance coverage:

- Discover nested templates while pruning migration directories
- Isolate workflow inputs and require local parameter metadata
- Assert complete parameter membership, values, comments, and precedence
- Verify component inference from deliberately incorrect initial values
- Preserve non-inferable component context
- Validate regeneration against independent configuration expectations
- Exercise real manager, component-editor, and parameter-editor workflows
- Verify preview-only startup and persistence requiring user permission
- Detect missing inference, saving, rules, context, and source parameters
- Copy templates before tests that can invalidate cached metadata

Signed-off-by: Dr.-Ing. Amilcar do Carmo Lucas <[email protected]>
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head e3adb17ad4.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/methodicconfigurator/2186/2.html#prMethodicConfigurator-2186

Follow-up after the rebase: this is for head e3adb17, the previous note was for a4cfaa8. The rebase only dropped the .gitignore hunk, so the earlier points still stand and I have re-checked each of them on the new head.

The pytest jobs still cannot pass. The reworked acceptance tests read apm.pdef.xml from the installed templates (tests/acceptance_template_import_from_params.py:386, tests/template_import_helpers.py:143). That file is gitignored and tracked for only 8 of the 29 templates, not for ArduCopter/empty_4.6.x or ArduPlane/empty_4.7.x, and the autouse fixture at tests/acceptance_template_import_from_params.py:166 blocks the download. In a clean checkout of e3adb17 I get 4 failed, 86 passed, 131 errors; with the XML present in every template the same file gives 221 passed, so the tests themselves look fine. CI for this head was still queued when I checked; CI for a4cfaa8, which has identical test files, failed with the same 4 failures and 131 errors. Could you commit or seed the XML the tests need, or skip clearly when it is absent?

Not blocking: in the generic template path, retain_unrepresented_fc_parameters (ardupilot_methodic_configurator/backend_filesystem.py:837) keeps every FC value that is not in a template step, including values still at their default. With a full 1020-parameter FC and empty_4.6.x the new final step has 732 entries, 731 of them defaults, where 'create from flight controller' writes 1 for the same input. That includes INS_ACCOFFS_* and INS_GYROFFS_* saved as 0, so after an accelerometer calibration the last step shows them as different from the FC, and the table's checkbox logic would select them for upload on a live link (I ran the editor's data model and read the checkbox code; I did not upload to a real FC). The calibration plugin does warn about stale values in other steps, so this is a stale snapshot to review, not a silent reset. Filtering against the FC defaults when they are available, as _complete_imported_vehicle_project_creation does, would avoid it.

Minor: a retention failure is still reported as 'Copying template files' instead of 'Parameter import' (ardupilot_methodic_configurator/data_model_vehicle_project_creator.py:550), as Copilot also noted. The cleanup itself works.

Copilot's other point, the missing cleanup when the residual export fails in the 'create from flight controller' workflow, behaves the same on master and on this branch, so it is not from this PR; it would be good to fix separately.

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

AIReview Request an automated AI review; picked up by the reviewprs sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants