Skip to content

Add runtime packages for generated code - #441

Open
christophfroehlich wants to merge 9 commits into
mainfrom
runtime-packages
Open

christophfroehlich wants to merge 9 commits into
mainfrom
runtime-packages

Conversation

@christophfroehlich

Copy link
Copy Markdown
Collaborator

Supersedes the dependency-type reshuffle in #354. Bloom puts exec_depend, build_export_depend and buildtool_export_depend all into a deb's Depends: (bloom), so retagging dependencies inside generate_parameter_library cannot keep the generator off a robot. Like rosidl_default_generators / rosidl_default_runtime (and NoDL's nodl_runtime_py), this splits what generated code needs at runtime into separate packages:

  • generate_parameter_library_runtime_cpp (new, C++): manifest-only package with what the generated header links (fmt, rclcpp, rclcpp_lifecycle, rsl) and the header-only libs the generated CMake target exports (tcb_span, libexpected-dev).

  • generate_parameter_library_runtime_py (new, Python): ParameterValidators moves here from generate_parameter_library_py (resolves the TODO in python_validators.py), plus rclpy and rcl_interfaces. Generated modules and generate_parameter_library_validate import it from here. generate_parameter_library_py.python_validators stays as a re-export.

  • generate_parameter_library now depends on both runtime packages instead of listing their contents, so <depend>generate_parameter_library</depend> keeps working unchanged.

  • The examples use the lean pattern, documented in the README:

    <build_depend>generate_parameter_library</build_depend>
    <depend>generate_parameter_library_runtime_cpp</depend>
  • CI pip-installs and tests the new Python package. A new Lean Runtime workflow builds the examples, then runs them in a fresh ros-core container that only has the exec dependencies of the runtime packages and examples, without the generator.

A new test checks that generated Python modules import only the runtime package, rclpy, rcl_interfaces and the standard library.

Behaviour change for a plain <depend>generate_parameter_library</depend>: since #440 that no longer pulled in rclpy. It does again now, via generate_parameter_library_py → generate_parameter_library_runtime_py → rclpy and rcl_interfaces, because the validate CLI imports the moved validators. C++-only packages that want neither the generator nor rclpy at runtime should switch to the pattern above.

Custom validation modules that import generate_parameter_library_py.python_validators should switch to generate_parameter_library_runtime_py.python_validators; the old path only works where the generator is installed.

Release note: both new packages have to be added to the rosdistro release.

🤖 Generated with Claude Code

christophfroehlich and others added 7 commits November 19, 2026 22:31
… package

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The runtime dependency is not declared as a test dependency, so clean Debian builds with tests enabled may fail during test collection.

1 open issue
What changed in this PR

Separates runtime support for generated ROS parameter code from the build-time generators, allowing deployed packages to avoid generator dependencies.

Changes:

  • Adds dedicated C++ and Python runtime packages.
  • Moves Python validators into the runtime package while preserving the old import path.
  • Updates examples, documentation, and CI to support and verify lean deployments.
File Description
README.md Documents lean dependency patterns and updated installation commands.
generate_parameter_library/​package.xml Replaces direct runtime dependencies with runtime packages.
generate_parameter_library_runtime_py/​test/​test_python_validators.py Tests validators through their new package path.
generate_parameter_library_runtime_py/​setup.py Defines Python runtime packaging.
generate_parameter_library_runtime_py/​resource/​generate_parameter_library_runtime_py Registers the runtime package with ament.
generate_parameter_library_runtime_py/​package.xml Declares Python runtime dependencies.
generate_parameter_library_runtime_py/​generate_parameter_library_runtime_py/​python_validators.py Houses the moved validator implementation.
generate_parameter_library_runtime_py/​generate_parameter_library_runtime_py/​__init__.py Marks the Python runtime module as a package.
generate_parameter_library_runtime_py/​CHANGELOG.rst Adds the Python runtime changelog heading.
generate_parameter_library_runtime_cpp/​package.xml Declares generated C++ code dependencies.
generate_parameter_library_runtime_cpp/​CMakeLists.txt Defines the manifest-only C++ runtime package.
generate_parameter_library_runtime_cpp/​CHANGELOG.rst Adds the C++ runtime changelog heading.
generate_parameter_library_py/​setup.py Adds the Python runtime installation dependency.
generate_parameter_library_py/​package.xml Declares the Python runtime execution dependency.
generate_parameter_library_py/​generate_parameter_library_py/​validate_config.py Imports validators from the runtime package.
generate_parameter_library_py/​generate_parameter_library_py/​test/​test_python_runtime_imports.py Checks generated modules for runtime-only imports.
generate_parameter_library_py/​generate_parameter_library_py/​python_validators.py Preserves compatibility through a validator re-export.
generate_parameter_library_py/​generate_parameter_library_py/​jinja_templates/​python/​parameter_library_header Generates imports from the runtime package.
example/​package.xml Adopts separate generator and C++ runtime dependencies.
example_python/​package.xml Separates Python build, runtime, and test dependencies.
example_cmake_python/​package.xml Adopts separate generator and Python runtime dependencies.
.github/​workflows/​rolling-semi-binary-build.yaml Installs the Python runtime alongside the generator.
.github/​workflows/​python-install-paths.yaml Includes the runtime package in installation and testing.
.github/​workflows/​lean-runtime.yaml Runs built examples without the generator installed.
.github/​workflows/​humble-semi-binary-build.yaml Installs the Python runtime alongside the generator.

Review effort: Balanced

…enerate_parameter_library_py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Generated modules can fail when the new runtime package is absent, and the isolation check can miss a generator installed in the sourced ROS environment.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Source the ROS environment before checking generator imports

.github/​workflows/​lean-runtime.yaml:98

The Python check runs before sourcing the ROS underlay or the extracted install space, so it cannot see a generator installed in either location. For example, an accidental runtime dependency on generate_parameter_library_py can install it under /opt/ros, yet this check still passes and the subsequent sourced examples can use it. Source the same environment as the examples before checking the import.

Medium severity Add a legacy validator fallback for older generator deployments

generate_parameter_library_py/​generate_parameter_library_py/​jinja_templates/​python/​parameter_library_header:15

A downstream Python package rebuilt with this template can still be deployed with the previous generator release, since its existing unversioned generate_parameter_library dependency does not require an upgrade. The new runtime package may then be absent, causing the generated module to fail with ModuleNotFoundError. Add a guarded fallback to the legacy validator import when the runtime package is absent, and adjust the import-isolation test to allow that fallback.

1 resolved since last review

Review effort: Balanced

…e job

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@christophfroehlich

Copy link
Copy Markdown
Collaborator Author

Re the latest review:

Source the ROS environment before checking generator imports: agreed. Container steps don't source /opt/ros, so an apt-installed generate_parameter_library_py would not have been found. Fixed in da49451: the check now runs after source install/setup.bash and uses ros2 pkg prefix for both generator packages, which covers /opt/ros and the install space.

Legacy validator fallback for older generator deployments: not adding this. The failure needs a partial upgrade, where a downstream package rebuilt against the new generator is installed next to an old generate_parameter_library. ROS binary packages are synced and meant to be upgraded together. Any downstream rebuilt against a newer dependency breaks the same way on a partial upgrade, e.g. generated C++ code calling a new rsl function. A try/except import of generate_parameter_library_py in every generated module would bring back the generator import this PR removes, and the lean pattern declares the runtime package directly anyway.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A missing legacy import fallback and missing Python generator version constraints can cause generated modules to fail to import on existing installations and lean deployments.

No open issues 🎉

4 previously missed issues

In code that hasn't changed since last review

High severity Require a Python generator version with the updated template

example_python/​package.xml:14

These lean Python manifests accept an older Python generator that still emits imports from generate_parameter_library_py, so those modules fail to import on a generator-free target. Require a version of the actual Python generator containing the updated template, including through the CMake dependency route. Same issue in example_cmake_python/package.xml:15 and the Python recipes in README.md:67–73.

High severity Preserve legacy validator import fallback

generate_parameter_library_py/​generate_parameter_library_py/​jinja_templates/​python/​parameter_library_header:15

Newly generated modules fail to import on targets that satisfy an existing unversioned <depend>generate_parameter_library</depend> with an older generator, because that installation does not pull in the new runtime package. Keep the legacy validator import as a fallback when the runtime package is absent, and adjust the import test to allow only that fallback.

Medium severity Check runtime dependencies before packing the install space

.github/​workflows/​lean-runtime.yaml:55

The archive retains the runtime packages even if an example omits its runtime dependency, so this workflow can miss a broken deployment manifest. Validate each example's runtime declaration before packing the install space.

Medium severity Require nodes to remain running until the timeout

.github/​workflows/​lean-runtime.yaml:108

This helper also succeeds when the command exits with status 0 before the timeout, so a node that exits without starting can make the lean-runtime check pass. Require the timeout status explicitly so both examples must remain running for the full check.

Review effort: Balanced

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.

2 participants