Add support for the --help argument in the examples#731
Conversation
|
Warning Rate limit exceeded@nvtw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 5 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughcreate_parser now accepts add_help and init accepts an external parser; when an external parser is provided init uses parser.parse_args(), otherwise it falls back to create_parser()+parse_known_args(). Many example scripts now build a parser with add_help=True, set descriptions, and pass it into init; one example calls run() after init. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Script as Example Script
participant Examples as newton.examples
participant Argparse as argparse
participant Viewer as Viewer/Env
User->>Script: run with CLI args
Script->>Examples: create_parser(add_help=True)
Examples->>Argparse: ArgumentParser(add_help=True)
Argparse-->>Examples: parser
Script->>Examples: init(parser)
alt external parser provided
Examples->>Argparse: parser.parse_args()
Argparse-->>Examples: args (strict)
else no external parser
Examples->>Examples: create_parser()
Examples->>Argparse: parser.parse_known_args()
Argparse-->>Examples: args + unknown
end
Examples->>Viewer: initialize with args
Viewer-->>Script: viewer, args
Script->>Viewer: run example loop (optional explicit run)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🧪 Generate 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
newton/examples/selection/example_selection_articulations.py (1)
296-301: Fix Torch device selection API and guard against None.
torch.set_deviceis not a public API; usetorch.cuda.set_devicewhen a CUDA device is requested, and skip otherwise to avoid exceptions when--deviceis unset or CPU.if USE_TORCH: - import torch - - torch.set_device(args.device) + import torch + if getattr(args, "device", None): + if str(args.device).startswith("cuda"): + import torch.cuda + torch.cuda.set_device(torch.device(args.device)) + # else: CPU or other backends; no-op here to avoid surprising global defaults
🧹 Nitpick comments (28)
newton/examples/__init__.py (2)
104-117: Good: add_help surfaced to callersPassing add_help through fixes --help in examples. Minor nit: tighten the docstring and inline comment to reflect the parameterized behavior.
Apply:
-def create_parser(add_help=False): - """Create a base argument parser with common parameters for Newton examples. +def create_parser(add_help: bool = False): + """Create a base argparse parser with common parameters for Newton examples. @@ - Individual examples can use this as a parent parser and add their own - specific arguments. + Individual examples can use this as a parent parser and add their own specific arguments. + + Args: + add_help: If True, enable -h/--help on the returned parser. Keep False when using this + as a parent parser to avoid duplicate help. @@ - argparse.ArgumentParser: Base parser with common arguments + argparse.ArgumentParser: Base parser with common arguments. """ @@ - # add_help=False since this is a parent parser - parser = argparse.ArgumentParser(add_help=add_help, formatter_class=argparse.ArgumentDefaultsHelpFormatter) + # Pass through add_help so examples can opt-in to -h/--help + parser = argparse.ArgumentParser(add_help=add_help, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
139-151: Docstring param type is incorrectinit(parser=None) takes an ArgumentParser, not “Parsed arguments”. Update docstring to avoid confusion.
- Args: - parser: Parsed arguments from argparse (should include arguments from - create_parser()) + Args: + parser: An argparse.ArgumentParser configured with create_parser(), or None.newton/examples/cloth/example_cloth_hanging.py (1)
197-197: LGTM: help enabled for this exampleConsider adding a short description so -h output is more informative.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Simulate a hanging cloth under gravity with multiple solver backends."newton/examples/robot/example_robot_ur10.py (1)
211-211: LGTM: help enabledOptional: set a description to improve --help UX.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "UR10 robot demo with sinusoidal joint targets replicated across environments."newton/examples/diffsim/example_diffsim_spring_cage.py (1)
243-243: LGTM: help enabledOptional: add a concise description for the help screen.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Optimize spring rest lengths to pull a particle towards a target (diffsim)."newton/examples/ik/example_ik_benchmark.py (1)
366-379: LGTM: help enabled; sensible default viewerNice touch setting viewer="null" for a non-visual benchmark. Optionally add a brief description.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Benchmark Newton IK on Franka across varying batch sizes and report timing/accuracy."newton/examples/robot/example_robot_policy.py (1)
410-421: Improve help UX: set description/epilog.Add a short description and a usage example so --help is more informative.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = ("Control a pretrained robot policy via keyboard " + "(space=start, p=reset, i/j/k/l/u/o=motion).") + parser.epilog = "Example: python -m newton.examples robot_policy --robot go2 --viewer gl"newton/examples/mpm/example_mpm_granular.py (1)
158-166: Clarify help output with description/epilog.Make --help output self-explanatory.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Implicit MPM granular demo with optional collider and emission bounds." + parser.epilog = "Example: python -m newton.examples mpm_granular --collider cube --viewer gl"newton/examples/basic/example_basic_urdf.py (1)
136-144: Add description/epilog for clearer --help.- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Basic URDF quadruped demo (no trained policy)." + parser.epilog = "Example: python -m newton.examples basic_urdf --num-envs 16"newton/examples/mpm/example_mpm_anymal.py (1)
385-397: Enhance help text.- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Anymal C robot walking on implicit MPM sand with a pretrained policy." + parser.epilog = "Example: python -m newton.examples mpm_anymal --viewer gl"newton/examples/robot/example_robot_g1.py (1)
135-141: Polish --help output with description/epilog.- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Unitree G1 from USD; replicates multiple environments." + parser.epilog = "Example: python -m newton.examples robot_g1 --num-envs 16"newton/examples/cloth/example_cloth_twist.py (1)
296-301: Optional: surface a concise description in -h outputAdd a description so help shows what this example does.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Twist an FEM cloth model with VBD self-contact; intersection-free cloth twisting demo."newton/examples/selection/example_selection_materials.py (2)
260-271: Avoid double argument parsing; let init(parser) own itparse_known_args() is redundant and can cause duplicated parsing/early exit on -h. Drop it and rely on init(parser).
- args = parser.parse_known_args()[0] - - viewer, args = newton.examples.init(parser) + viewer, args = newton.examples.init(parser)
260-267: Optional: add a description for clearer --help outputBriefly describe the example for users scanning help.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Batch material edits via Selection API: ants with randomized friction, toggling direction."newton/examples/robot/example_robot_cartpole.py (1)
117-121: Optional: add a help descriptionImproves discoverability in CLI help.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "USD-based cartpole replication; rigid-body control with MuJoCo solver."newton/examples/diffsim/example_diffsim_cloth.py (1)
217-221: Optional: set parser.descriptionShows the optimization objective in -h output.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Differentiable cloth: optimize initial velocities so COM hits a target."newton/examples/cloth/example_cloth_franka.py (1)
559-563: Optional: add a CLI descriptionHelps users quickly identify the demo from -h.
- parser = newton.examples.create_parser(add_help=True) + parser = newton.examples.create_parser(add_help=True) + parser.description = "Franka + cloth manipulation: hybrid Featherstone/VBD with cloth self-contact."newton/examples/diffsim/example_diffsim_soft_body.py (1)
361-361: Good: help enabled; consider adding a description for consistent-houtput.Passing
add_help=Trueis correct. For consistency with other examples, setparser.descriptionso--helpshows a useful summary.parser = newton.examples.create_parser(add_help=True) +parser.description = "Optimize soft-body material parameters via differentiable simulation."newton/examples/selection/example_selection_articulations.py (1)
292-295: Remove redundant pre-parse; letinit(parser)own parsing.
parser.parse_known_args()is unnecessary and can confuse future readers sinceinit(parser)re-parses withparse_args()(and handles--help). Remove it.-args = parser.parse_known_args()[0] - viewer, args = newton.examples.init(parser)newton/examples/diffsim/example_diffsim_ball.py (1)
248-253: Add a parser.description for consistent help outputInclude a description on the parser in this example for uniform help messages:
parser = newton.examples.create_parser(add_help=True) +parser.description = "Optimize initial particle velocity via differentiable simulation to hit a target."Static checks confirm all examples already call
create_parser(add_help=True)and pass the parser intoinit().newton/examples/basic/example_basic_joints.py (1)
210-210: Avoid unused variable: rename args to underscoreargs isn’t used; keep linters quiet by discarding it.
- viewer, args = newton.examples.init(parser) + viewer, _ = newton.examples.init(parser)newton/examples/basic/example_basic_shapes.py (2)
151-151: Drop unused args bindingargs isn’t referenced; prefer underscore.
- viewer, args = newton.examples.init(parser) + viewer, _ = newton.examples.init(parser)
144-148: Doc/test follow-up for migration itemSince the PR description mentions updating docs/migration.rst and tests for examples, confirm those land before merge; I can draft a minimal pytest that asserts each example’s --help exits with code 0.
newton/examples/robot/example_robot_anymal_c_walk.py (1)
237-238: Rename unused argsMinor lint fix.
- viewer, args = newton.examples.init(parser) + viewer, _ = newton.examples.init(parser)newton/examples/ik/example_ik_franka.py (1)
178-179: Ignore unused argsKeep it tidy.
- viewer, args = newton.examples.init(parser) + viewer, _ = newton.examples.init(parser)newton/examples/basic/example_basic_pendulum.py (1)
139-139: Use underscore for unused args- viewer, args = newton.examples.init(parser) + viewer, _ = newton.examples.init(parser)newton/examples/ik/example_ik_h1.py (1)
190-196: Polish: show the recommended invocation in help usage.Set
parser.progso the Usage line reflectspython -m newton.examples ik_h1instead of the script path.Apply this diff:
parser = newton.examples.create_parser(add_help=True) parser.description = "Demonstrates inverse kinematics for H1 humanoid robot using Newton physics." +parser.prog = "python -m newton.examples ik_h1"newton/examples/basic/example_basic_viewer.py (1)
192-196: Nit: clarify help usage with the module entrypoint.Explicitly set
parser.progto the documented command to make the Usage line friendlier.Apply this diff:
parser = newton.examples.create_parser(add_help=True) parser.description = ( "Shows how to use different viewer types (GL, USD, Rerun, Null) with Newton physics simulation." ) +parser.prog = "python -m newton.examples basic_viewer" -viewer, args = newton.examples.init(parser) +viewer, args = newton.examples.init(parser)Also applies to: 199-199
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (32)
newton/examples/__init__.py(3 hunks)newton/examples/basic/example_basic_joints.py(1 hunks)newton/examples/basic/example_basic_pendulum.py(1 hunks)newton/examples/basic/example_basic_shapes.py(1 hunks)newton/examples/basic/example_basic_urdf.py(1 hunks)newton/examples/basic/example_basic_viewer.py(1 hunks)newton/examples/cloth/example_cloth_bending.py(1 hunks)newton/examples/cloth/example_cloth_franka.py(1 hunks)newton/examples/cloth/example_cloth_hanging.py(1 hunks)newton/examples/cloth/example_cloth_style3d.py(1 hunks)newton/examples/cloth/example_cloth_twist.py(1 hunks)newton/examples/diffsim/example_diffsim_ball.py(1 hunks)newton/examples/diffsim/example_diffsim_cloth.py(1 hunks)newton/examples/diffsim/example_diffsim_drone.py(1 hunks)newton/examples/diffsim/example_diffsim_soft_body.py(1 hunks)newton/examples/diffsim/example_diffsim_spring_cage.py(1 hunks)newton/examples/ik/example_ik_benchmark.py(1 hunks)newton/examples/ik/example_ik_franka.py(1 hunks)newton/examples/ik/example_ik_h1.py(1 hunks)newton/examples/mpm/example_mpm_anymal.py(1 hunks)newton/examples/mpm/example_mpm_granular.py(1 hunks)newton/examples/robot/example_robot_anymal_c_walk.py(1 hunks)newton/examples/robot/example_robot_anymal_d.py(1 hunks)newton/examples/robot/example_robot_cartpole.py(1 hunks)newton/examples/robot/example_robot_g1.py(1 hunks)newton/examples/robot/example_robot_h1.py(1 hunks)newton/examples/robot/example_robot_humanoid.py(1 hunks)newton/examples/robot/example_robot_policy.py(1 hunks)newton/examples/robot/example_robot_ur10.py(1 hunks)newton/examples/selection/example_selection_articulations.py(1 hunks)newton/examples/selection/example_selection_cartpole.py(1 hunks)newton/examples/selection/example_selection_materials.py(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: dylanturpin
PR: newton-physics/newton#634
File: newton/tests/test_examples.py:329-333
Timestamp: 2025-08-25T21:41:45.795Z
Learning: Newton examples use a centralized CLI argument parsing system in newton/examples/__init__.py. The create_parser() function defines common arguments like --device, --viewer, --output-path, and --num-frames, while init(parser) creates viewers based on parsed arguments. Individual example scripts don't need to define these flags themselves - they inherit them from the centralized system via the example_map and runpy execution.
📚 Learning: 2025-08-25T21:41:45.795Z
Learnt from: dylanturpin
PR: newton-physics/newton#634
File: newton/tests/test_examples.py:329-333
Timestamp: 2025-08-25T21:41:45.795Z
Learning: Newton examples use a centralized CLI argument parsing system in newton/examples/__init__.py. The create_parser() function defines common arguments like --device, --viewer, --output-path, and --num-frames, while init(parser) creates viewers based on parsed arguments. Individual example scripts don't need to define these flags themselves - they inherit them from the centralized system via the example_map and runpy execution.
Applied to files:
newton/examples/cloth/example_cloth_hanging.pynewton/examples/mpm/example_mpm_granular.pynewton/examples/robot/example_robot_ur10.pynewton/examples/robot/example_robot_policy.pynewton/examples/robot/example_robot_anymal_d.pynewton/examples/robot/example_robot_cartpole.pynewton/examples/cloth/example_cloth_twist.pynewton/examples/basic/example_basic_urdf.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/basic/example_basic_joints.pynewton/examples/robot/example_robot_humanoid.pynewton/examples/__init__.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/basic/example_basic_shapes.pynewton/examples/basic/example_basic_pendulum.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/ik/example_ik_h1.pynewton/examples/cloth/example_cloth_bending.pynewton/examples/ik/example_ik_benchmark.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/robot/example_robot_h1.pynewton/examples/robot/example_robot_g1.pynewton/examples/mpm/example_mpm_anymal.pynewton/examples/selection/example_selection_cartpole.pynewton/examples/cloth/example_cloth_franka.pynewton/examples/selection/example_selection_articulations.pynewton/examples/selection/example_selection_materials.pynewton/examples/cloth/example_cloth_style3d.pynewton/examples/basic/example_basic_viewer.pynewton/examples/ik/example_ik_franka.py
📚 Learning: 2025-08-27T19:05:44.697Z
Learnt from: Milad-Rakhsha-NV
PR: newton-physics/newton#535
File: newton/tests/test_examples.py:320-414
Timestamp: 2025-08-27T19:05:44.697Z
Learning: In newton/examples/__init__.py, the robot policy example is registered with the key "robot_policy" (not "robot.example_robot_policy"), so tests should reference it as name="robot_policy".
Applied to files:
newton/examples/robot/example_robot_policy.py
🧬 Code graph analysis (31)
newton/examples/cloth/example_cloth_hanging.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/mpm/example_mpm_granular.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_ur10.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_policy.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_anymal_d.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_cartpole.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/cloth/example_cloth_twist.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/basic/example_basic_urdf.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/diffsim/example_diffsim_spring_cage.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/basic/example_basic_joints.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/robot/example_robot_humanoid.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/diffsim/example_diffsim_drone.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/basic/example_basic_shapes.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/basic/example_basic_pendulum.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/diffsim/example_diffsim_cloth.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_anymal_c_walk.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/diffsim/example_diffsim_ball.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/ik/example_ik_h1.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/cloth/example_cloth_bending.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/ik/example_ik_benchmark.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/diffsim/example_diffsim_soft_body.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_h1.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/robot/example_robot_g1.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/mpm/example_mpm_anymal.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/selection/example_selection_cartpole.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/cloth/example_cloth_franka.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/selection/example_selection_articulations.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/selection/example_selection_materials.py (1)
newton/examples/__init__.py (1)
create_parser(104-136)
newton/examples/cloth/example_cloth_style3d.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/basic/example_basic_viewer.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
newton/examples/ik/example_ik_franka.py (1)
newton/examples/__init__.py (2)
create_parser(104-136)init(139-182)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run GPU Benchmarks (Pull Request)
- GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
- GitHub Check: run-newton-tests / newton-unittests (ubuntu-latest)
- GitHub Check: run-newton-tests / newton-unittests (windows-latest)
🔇 Additional comments (29)
newton/examples/__init__.py (1)
159-163: All examples pass a parser into init; no flags will be dropped.newton/examples/robot/example_robot_policy.py (2)
413-413: Enable --help: Good change.Passing add_help=True correctly exposes -h/--help for this example.
410-421: No remaining create_parser calls missing add_help=True – grep search across newton/examples found no instances ofcreate_parserwithoutadd_help=True.newton/examples/mpm/example_mpm_granular.py (1)
162-162: Enable --help: Good change.This aligns with the centralized CLI.
newton/examples/basic/example_basic_urdf.py (1)
139-139: Enable --help: Good change.Consistent with the examples’ parser pattern.
newton/examples/mpm/example_mpm_anymal.py (1)
389-389: Enable --help: Good change.Matches the add_help-enabled parser API.
newton/examples/robot/example_robot_g1.py (1)
136-136: Enable --help: Good change.Keeps CLI consistent across examples.
newton/examples/robot/example_robot_h1.py (1)
129-136: Enable --help: LGTMUsing
create_parser(add_help=True)is correct and consistent with the centralized parser API.newton/examples/robot/example_robot_anymal_d.py (1)
141-149: Enable --help: LGTM
add_help=Truecorrectly exposes-h/--helpfor this example.newton/examples/robot/example_robot_humanoid.py (1)
120-128: Enable --help: LGTMMatches the updated
create_parser(add_help=False)signature and usage pattern.newton/examples/diffsim/example_diffsim_drone.py (1)
794-822: Enable --help: LGTMHelp is now available; no further changes needed here.
newton/examples/selection/example_selection_cartpole.py (1)
183-203: Remove redundant manual parse call
Drop theargs = parser.parse_known_args()[0]line—newton.examples.init(parser)already performs argument parsing (including help), avoiding a double-parse and hidden flags.newton/examples/cloth/example_cloth_twist.py (1)
296-301: Enabling --help via add_help=True looks goodMatches the new create_parser(add_help=...) API and keeps per-example defaults via set_defaults.
newton/examples/robot/example_robot_cartpole.py (1)
117-123: Good switch to add_help=TrueEnables -h/--help without altering runtime behavior.
newton/examples/diffsim/example_diffsim_cloth.py (1)
217-223: add_help=True adoption LGTMConsistent with the new parser API; custom --verbose flag integrates cleanly.
newton/examples/cloth/example_cloth_franka.py (1)
559-566: add_help=True change looks correctKeeps example-specific defaults via set_defaults(num_frames=3850).
newton/examples/selection/example_selection_articulations.py (1)
289-291: LGTM:--helpwired correctly.Creating the parser with
add_help=Truealigns with the new init flow.newton/examples/cloth/example_cloth_style3d.py (2)
185-187: Nice: descriptive help text.Setting
add_help=Trueandparser.descriptionimproves UX.
189-190: LGTM: delegate parsing toinit(parser).This ensures
-h/--helpexits as expected.newton/examples/cloth/example_cloth_bending.py (2)
135-137: Good: help enabled with summary.Consistent with other examples; no issues.
139-140: LGTM: central parsing viainit(parser).Correctly switches to the new init contract.
newton/examples/diffsim/example_diffsim_ball.py (1)
248-248: LGTM: help wired in.
add_help=Trueis correct, and you pass the parser toinit(parser).newton/examples/basic/example_basic_joints.py (1)
205-208: Add --help wiring via external parser: LGTMUsing create_parser(add_help=True), setting description, and passing the parser into init() correctly enables argparse’s built-in help behavior for direct script runs.
newton/examples/basic/example_basic_shapes.py (1)
144-148: Help-enabled CLI in main: looks goodDescription is concise and will show up in -h output. Good use of the shared parser.
newton/examples/robot/example_robot_anymal_c_walk.py (1)
233-236: CLI help support change is correctParser with add_help=True and description wired before init(parser) is consistent with the shared CLI contract.
newton/examples/ik/example_ik_franka.py (1)
174-177: Help flow LGTMExternal parser + description before init(parser) correctly enables --help for direct execution.
newton/examples/basic/example_basic_pendulum.py (1)
134-137: Good: standardized help-enabled parser usageMatches the new pattern; description is clear.
newton/examples/ik/example_ik_h1.py (1)
190-196: Good adoption of centralized parser with --help support.Using
create_parser(add_help=True)and passing it intoinit(parser)correctly enables--helpand aligns with the examples’ centralized CLI.newton/examples/basic/example_basic_viewer.py (1)
192-196: Nice, consistent --help plumbing via centralized parser.This mirrors the new
create_parser(...)/init(parser)flow and will print coherent help for viewer options.Also applies to: 199-199
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
newton/tests/test_examples.py (1)
56-57: OK to make list handling mutually exclusive; consider tuple support and empty-list guardSemantics are unchanged, but broadening to tuples and skipping empty sequences avoids emitting a bare
--keywhen[]is passed.- elif isinstance(value, list): - additional_options.extend([f"--{key.replace('_', '-')}"] + [str(v) for v in value]) + elif isinstance(value, (list, tuple)): + if value: # avoid emitting a bare flag when the sequence is empty + additional_options.extend([f"--{key.replace('_', '-')}"] + [str(v) for v in value])
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
newton/tests/test_examples.py(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: dylanturpin
PR: newton-physics/newton#634
File: newton/tests/test_examples.py:329-333
Timestamp: 2025-08-25T21:41:45.795Z
Learning: Newton examples use a centralized CLI argument parsing system in newton/examples/__init__.py. The create_parser() function defines common arguments like --device, --viewer, --output-path, and --num-frames, while init(parser) creates viewers based on parsed arguments. Individual example scripts don't need to define these flags themselves - they inherit them from the centralized system via the example_map and runpy execution.
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
- GitHub Check: Run GPU Benchmarks (Pull Request)
- GitHub Check: run-newton-tests / newton-unittests (windows-latest)
- GitHub Check: run-newton-tests / newton-unittests (ubuntu-latest)
mmacklin
left a comment
There was a problem hiding this comment.
Approved with comment to make add_help=True the default or remove (even better).
…adding help the new default
Description
Implements #668
Newton Migration Guide
Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this PR.
docs/migration.rstis up-to dateBefore your PR is "Ready for review"
newton/tests/test_examples.py)pre-commit run -aSummary by CodeRabbit
New Features
Bug Fixes
Documentation