Skip to content

Fix deprecated example API usage - #3991

Draft
jcarius-nv wants to merge 2 commits into
newton-physics:mainfrom
jcarius-nv:jcarius/fix-example-deprecations
Draft

Fix deprecated example API usage#3991
jcarius-nv wants to merge 2 commits into
newton-physics:mainfrom
jcarius-nv:jcarius/fix-example-deprecations

Conversation

@jcarius-nv

@jcarius-nv jcarius-nv commented Aug 20, 2026

Copy link
Copy Markdown
Member

Description

Follow-up to #3989. This PR must merge after #3989.

Migrate the five newly auto-discovered examples away from deprecated APIs and
remove their temporary strict-warning allowances. The examples now opt into
coordinate-layout joint targets where needed, the rigid-rigid VBD example uses
keyword arguments for add_shape_box(), and the RJ45 example no longer authors
the deprecated vbd:joint_is_hard attribute, which has no solver-mode effect
under its existing compliant ALM configuration.

This restores strict deprecation-warning enforcement for every auto-discovered
example.

GitHub's native stacked pull requests require all branches to live in the same
repository. Because #3989 is a cross-fork PR, this dependent PR temporarily
targets main and includes the parent changes in its comparison. The follow-up
change itself is commit a64ae9aa. After #3989 merges, this branch will be
rebased onto the updated main before this PR is marked ready.

Checklist

  • New or existing tests cover these changes
  • No documentation update is required for this API-use migration
  • This maintenance-only change does not require a changelog fragment

Test plan

python -W error::DeprecationWarning -m newton.examples <each-offender> \
  --device cuda:0 --test --quiet --viewer null
# All five examples passed individually.

uv run --extra dev -m newton.tests -k TestAutoDiscoveredExamples \
  --strict-warnings --no-cache-clear
# 15 passed in 186.444s

uvx --python 3.12 pre-commit run -a
# passed

Before the migration, each of the five example commands failed with a
DeprecationWarning treated as an error.

Summary by CodeRabbit

  • Improvements

    • Example test mode now consistently requires a test_final() validation step.
    • Automatically discovered examples receive baseline CUDA test coverage.
    • Several examples now support coordinate-layout targets and updated contact configurations.
  • Bug Fixes

    • Improved loading-screen behavior during example initialization and execution.
    • Added clearer validation when an example lacks the required final test.
  • Tests

    • Expanded coverage for example lifecycle behavior, automatic discovery, and viewer loading states.

Use example discovery as the CI coverage backstop while preserving tailored registrations. Require test_final() in test mode and document the contract.

Temporarily allow existing deprecation warnings for five newly covered examples. A follow-up will migrate them and remove the allowances.
Migrate the five newly covered examples to supported APIs and remove their temporary strict-warning allowances. This restores deprecation enforcement for every auto-discovered example.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47f6d7e3-1e79-45f0-9945-5ac9a0f3b0f3

📥 Commits

Reviewing files that changed from the base of the PR and between 6ee9f02 and a64ae9a.

📒 Files selected for processing (10)
  • docs/guide/development.rst
  • newton/examples/__init__.py
  • newton/examples/basic/example_basic_heightfield.py
  • newton/examples/contacts/example_contacts_rj45_plug.py
  • newton/examples/vbd/example_vbd_rigid_rigid_contact.py
  • newton/examples/vbd/example_vbd_soft_rigid_contact.py
  • newton/examples/vbd/example_vbd_soft_rigid_mix_contact.py
  • newton/tests/test_example_runner.py
  • newton/tests/test_examples.py
  • newton/tests/test_viewer_loading_splash.py

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The example runner now requires callable test_final() checks in test mode. Documentation describes automatic CUDA coverage for discovered examples. New lifecycle tests cover loading-splash behavior. Selected examples enable coordinate-layout targets and update VBD setup calls.

Changes

Example testing and initialization

Layer / File(s) Summary
Runner finalization contract
docs/guide/development.rst, newton/examples/__init__.py, newton/tests/test_example_runner.py, newton/tests/test_viewer_loading_splash.py
Test mode now validates callable test_final() before execution and calls it after the render loop. Lifecycle tests cover loading-splash behavior and the required error.
Automatic discovered-example coverage
docs/guide/development.rst, newton/tests/test_examples.py
Documentation and tests define automatic CUDA null-viewer coverage for examples without explicit registrations.
Example initialization compatibility
newton/examples/basic/example_basic_heightfield.py, newton/examples/contacts/example_contacts_rj45_plug.py, newton/examples/vbd/example_vbd_rigid_rigid_contact.py, newton/examples/vbd/example_vbd_soft_rigid_contact.py, newton/examples/vbd/example_vbd_soft_rigid_mix_contact.py
Selected examples enable coordinate-layout targets. The RJ45 plug example removes VBD custom attributes. Rigid contact shape calls use explicit keyword arguments.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a64ae

This localized maintenance change removes deprecated example API usage and restores strict warning enforcement; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: adenzler-nvidia

Sequence Diagram(s)

sequenceDiagram
  participant TestSuite
  participant newton.examples.init
  participant ViewerGL
  participant newton.examples.run
  participant Example
  TestSuite->>newton.examples.init: initialize example
  newton.examples.init->>ViewerGL: show loading splash for visible viewer
  TestSuite->>newton.examples.run: execute example
  newton.examples.run->>ViewerGL: hide loading splash
  newton.examples.run->>Example: call test_final() in test mode
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: migrating example code away from deprecated API usage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

1 participant