Skip to content

Scripts improvements - #2327

Merged
amilcarlucas merged 1 commit into
masterfrom
scripts_improvements
Nov 3, 2026
Merged

amilcarlucas merged 1 commit into
masterfrom
scripts_improvements

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

Description

This is a replacement for #2321 with a better branch name and some fixes

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 13:46
@amilcarlucas amilcarlucas added the AIReview Request an automated AI review; picked up by the reviewprs sweep label Nov 3, 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.

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

4 open issues
What changed in this PR

This PR improves various scripts and tests, notably updating how parameter metadata URLs are selected based on firmware version (historical vs modern upstream locations) and refactoring script internals for clearer behavior and logging.

Changes:

  • Update parameter metadata URL selection to use firmware.ardupilot.org for releases >= 4.7.0 and keep legacy URLs for older releases, with expanded unit tests.
  • Refactor screenshot regeneration and translation-extraction scripts for clearer flow and improved exception logging.
  • Remove legacy workflow/script related to generating and uploading apm.pdef.xml metadata.
File Description
tests/​test_backend_filesystem.py Expands test to validate metadata source URL across legacy/current releases.
tests/​test_annotate_params.py Adds coverage for version-boundary URL selection and vehicle directory mapping.
ardupilot_methodic_configurator/​annotate_params.py Implements upstream URL switch at 4.7.0 and adds firmware base URL constant.
scripts/​update_configuration_steps_translation.py Refactors extraction helpers and switches to logger.exception for full tracebacks.
scripts/​regenerate_app_screenshots_fully_automated.py Reduces duplication via helper functions/constants and improves error reporting.
scripts/​verify_wheel_install.py Improves RuntimeError message clarity when module import escapes venv.
scripts/​download_motor_diagrams.py Adjusts exception handling/logging for download failures.
scripts/​batch_convert_motor_diagrams.py Simplifies error handling by using logger.exception.
scripts/​calculate_code_statistics.py Removes redundant accumulator variable for generated app lines.
CUSTOMIZING_CONFIGURATION_STEPS.md Documents upstream metadata locations and URL formats by firmware version.
ARCHITECTURE_3_directory_selection.md Documents shared URL selection behavior and version split.
scripts/​generate_pdef.xml_metadata.py Removes legacy metadata generation/upload script.
.github/​workflows/​generate_apm.pdef.xml.yml Removes workflow that ran the removed metadata generation script.

Review effort: Lite

Comment on lines +109 to +110
except OSError:
logger.exception("Failed to download %s: ", filename)
Comment on lines 561 to +565
# Not yet versioned in the https://autotest.ardupilot.org/Parameters server
"AP_Periph": "versioned/Periph/stable-",
"Blimp": "versioned/Blimp/stable-",
"Heli": "versioned/Copter/stable-",
"SITL": "versioned/SITL/stable-",
"AP_Periph": "Periph",
"Blimp": "Blimp",
"Heli": "Copter",
"SITL": "SITL",

traceback.print_exc()
except (OSError, RuntimeError, ValueError):
logger.exception("Error during conversion: ")
Comment on lines +169 to +171
logger.exception("Error parsing %s:", config_file)
except Exception: # pylint: disable=broad-exception-caught
logger.exception("Error processing %s:", config_file)
ArduPilot owns parameter metadata generation and publication. Remove the
Methodic Configurator publisher and consume upstream release files while
simplifying script maintenance and preserving translation input.

Parameter metadata:
- Remove the duplicate metadata generator and its upload workflow.
- Download releases below 4.7.2 from the autotest versioned parameter
  directory, and releases from 4.7.2 onward from the firmware release's
  __METADATA__/apm.pdef.xml directory.
- Compare numeric major, minor, and patch components at the cutoff.
- Map vehicle names to the correct directories on each server.
- Preserve complete major.minor versions in ParameterRepository fallback
  URLs, including Plane 3.10 and Copter 4.10.
- Add snapshot fallbacks for Tracker, AP_Periph, and Blimp.
- Skip unavailable optional snapshots, including SITL, without preventing
  primary downloads or cached metadata from loading.
- Document upstream generation, publication layouts, cache precedence,
  and fallback policies.

Script maintenance:
- Extract configuration-step translation helpers while retaining popup
  messages, jump messages, and conditional change reasons.
- Consolidate screenshot widget lookup and bounding-box handling.
- Group screenshot handlers by signature and retain explicit checks for
  optional target fields.
- Use logger.exception instead of duplicate exception formatting and
  manual traceback printing.
- Remove an unused code-statistics accumulator.
- Improve diagnostics for wheel modules imported outside the isolated
  environment.

Validation:
- 264 affected tests pass, covering metadata routing, version boundaries,
  fallback downloads, cached metadata, translations, and packaging.
- All 32 screenshot targets retain their handler and arguments.
- Translation extraction preserves all 463 existing strings.
- Pre-commit, Markdown lint, and targeted static checks pass.
- Full screenshot regeneration and hardware tests were not run.

Signed-off-by: Dr.-Ing. Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
@AP-Review

Copy link
Copy Markdown

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

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

This refactor of the metadata URL selection and helper scripts looks correct at 755268e, and the 4.7.2 cutoff matches what the autotest and firmware servers publish today. The only open item is cosmetic.

Should fix

  • scripts/download_motor_diagrams.py:110: the new logger.exception() messages end in a dangling : before the traceback. The same happens in batch_convert_motor_diagrams.py:374, update_configuration_steps_translation.py:169/171/243/245 and regenerate_app_screenshots_fully_automated.py:1496. Drop the trailing colon.
Minor (1)
  • annotate_params.py:577: versions below 4.7.2 only ever try the autotest versioned tree. A future point release on an older series (e.g. 4.6.4) would probably only appear under firmware __METADATA__, and the standalone editor would then fail to find metadata. This is informational for now. Consider trying the firmware path first and falling back to autotest.

Copilot's concern that URLError is no longer caught does not hold, because URLError is an OSError subclass.

Not fully reviewed: real GUI screenshot regeneration, end-to-end motor-diagram download/conversion, frozen/PyInstaller builds, the full lint/type-check suite and upstream CI (still pending).

@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
29929 28368 95% 89% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 755268e by action🐍

@amilcarlucas
amilcarlucas merged commit 494142c into master Nov 3, 2026
29 of 32 checks passed
@amilcarlucas
amilcarlucas deleted the scripts_improvements branch November 3, 2026 18:53
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 41651882184

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.818%

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: 29929
Covered Lines: 28378
Line Coverage: 94.82%
Relevant Branches: 9022
Covered Branches: 8047
Branch Coverage: 89.19%
Branches in Coverage %: No
Coverage Strength: 2.83 hits per line

💛 - Coveralls

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.

4 participants