Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TryAllNavigationPolicy config exposed to python #3822

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Nov 6, 2024

I previously neglected to include the overload with the configuration in the python bindings. This PR does that and also includes test coverage for this behavior.

Summary by CodeRabbit

  • New Features

    • Introduced a new method to the navigation policy factory for adding TryAllNavigationPolicy with configuration parameters.
    • Added Python bindings for the TryAllNavigationPolicy::Config class.
  • Bug Fixes

    • Adjusted constructor parameter order for TryAllNavigationPolicy, enhancing clarity and usability.
  • Tests

    • Added a new test function to validate the addition of TryAllNavigationPolicy with specific configuration options.

@paulgessinger paulgessinger added this to the next milestone Nov 6, 2024
Copy link

coderabbitai bot commented Nov 6, 2024

Walkthrough

Change significant, it is. The constructor of TryAllNavigationPolicy restructured, parameters reordered they are. From Config first to GeometryContext first, the order has shifted. Documentation updated, clarity maintained. In Navigation.cpp, a new method added to AnyNavigationPolicyFactory, allowing configuration when adding TryAllNavigationPolicy. Tests expanded, coverage increased with new function.

Changes

File Change Summary
Core/include/Acts/Navigation/TryAllNavigationPolicy.hpp, Core/src/Navigation/TryAllNavigationPolicy.cpp Constructor parameter order updated in TryAllNavigationPolicy. Documentation adjusted accordingly.
Examples/Python/src/Navigation.cpp New method added to AnyNavigationPolicyFactory for TryAllNavigationPolicy::Config. Python bindings updated.
Examples/Python/tests/test_navigation.py New test function test_try_all_arguments added to verify behavior with specific configuration.

Poem

In the code, a shift so bright,
Parameters dance, a new delight.
Navigation flows with ease anew,
Configs added, tests to pursue.
Yoda smiles, for progress is clear,
In every line, a change we cheer! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module labels Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

📊: Physics performance monitoring for 92033d7

Full contents

physmon summary

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range comments (2)
Core/src/Navigation/TryAllNavigationPolicy.cpp (1)

Line range hint 25-29: Documentation improvement, suggest I do.

Clear the code is, but wisdom in comments, share we must. Help future Padawans understand the empty config's purpose, it would.

Add this comment above the constructor, you should:

+// Convenience constructor that delegates to the main constructor with default config
 TryAllNavigationPolicy::TryAllNavigationPolicy(const GeometryContext& gctx,
                                               const TrackingVolume& volume,
                                               const Logger& logger)
     : TryAllNavigationPolicy(gctx, volume, logger, {}) {}
Examples/Python/src/Navigation.cpp (1)

Line range hint 1-224: Architecture advice, share I must!

Consider these suggestions, young Padawan:

  1. Documentation comments for Python bindings, add you should. Help users understand Config parameters, it will.
  2. Type hints in Python interface, beneficial they would be. Clear API contract, they provide.

Generate documentation and type hints for you, shall I?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 8c1f155 and a1dbcc9.

📒 Files selected for processing (4)
  • Core/include/Acts/Navigation/TryAllNavigationPolicy.hpp (1 hunks)
  • Core/src/Navigation/TryAllNavigationPolicy.cpp (2 hunks)
  • Examples/Python/src/Navigation.cpp (5 hunks)
  • Examples/Python/tests/test_navigation.py (1 hunks)
🧰 Additional context used
🪛 Ruff
Examples/Python/tests/test_navigation.py

45-45: Missing return type annotation for public function test_try_all_arguments

Add return type annotation: None

(ANN201)


47-47: Trailing comma missing

Add trailing comma

(COM812)

🔇 Additional comments (8)
Core/src/Navigation/TryAllNavigationPolicy.cpp (2)

Line range hint 16-23: Hmmmm, good changes these are!

Wise, the new parameter order is. GeometryContext first, as the Force flows through all things, it should be. Strong and clear, the initialization remains.


Line range hint 16-29: Verify all usages of TryAllNavigationPolicy, we must.

Changed the constructor parameter order has. Ensure all instantiations throughout the codebase updated are, we must.

Core/include/Acts/Navigation/TryAllNavigationPolicy.hpp (1)

33-36: ⚠️ Potential issue

Hmmmm, breaking change in constructor parameters, I sense.

Moved to the end, the Config parameter has been. A breaking change this is, affecting all existing code that creates TryAllNavigationPolicy instances. Wise decision it may be, as optional parameter at the end it becomes, matching the signature of the other constructor it does.

Examples/Python/src/Navigation.cpp (5)

40-43: Hmmmm, good addition this is!

Pure virtual function for TryAllNavigationPolicy with Config, added it has been. Consistent with existing pattern for SurfaceArrayNavigationPolicy, it is.


68-72: Implementation, well structured it is!

Follows the established pattern, this override does. Forwards configuration correctly to the templated add method, it does.


121-125: Clear and concise, this implementation is!

Similar to addSurfaceArray method, consistency maintained it has. Return reference for method chaining, wise choice it is.


190-190: Python method exposed, complete the circle does!

New addTryAll method, properly bound to Python it is. Matches C++ interface, harmony achieved it has.


172-181: Python bindings, properly scoped they are!

In local scope, Config class defined it is. ACTS_PYTHON_STRUCT macros, correctly used they are. But verify the exposed members we must!

✅ Verification successful

I need to see both the test usage and the actual implementation to verify if the exposed members (portals and sensitives) are correctly bound. This will help us determine if the Force is balanced in our Python bindings.


Hmm, in the Core directory it was not. Search the entire repository, we must! The path of the implementation file, find we shall. Then verify the Config members, we can.


Balanced, the Force in these bindings is!

Verified the exposed members have been, hmm! In the source code, two members we find - portals and sensitives, both boolean they are. In the Python test, used correctly they are, as shown here: Config(sensitives=True). Match perfectly with the C++ implementation, these bindings do!

The path to enlightenment shows:

  • In Core/include/Acts/Navigation/TryAllNavigationPolicy.hpp, Config members defined they are
  • In Python tests, properly accessed these members are
  • ACTS_PYTHON_MEMBER macros, correctly expose both portals and sensitives they do
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for TryAllNavigationPolicy::Config usage in tests
rg -l "TryAllNavigationPolicy.*Config" "Examples/Python/tests/"

Length of output: 104


Script:

#!/bin/bash
# Examine the test file to see how Config is used
cat Examples/Python/tests/test_navigation.py

Length of output: 1212


Script:

#!/bin/bash
# Check the actual TryAllNavigationPolicy class definition
rg -A 10 "class TryAllNavigationPolicy" Examples/Core/include/

Length of output: 127


Script:

#!/bin/bash
# Look for Config struct definition
ast-grep --pattern 'struct Config {
  $$$
}'

Length of output: 46


Script:

#!/bin/bash
# Search for TryAllNavigationPolicy in the entire codebase
rg -A 10 "class TryAllNavigationPolicy" 

Length of output: 961


Script:

#!/bin/bash
# Look for the implementation file
fd "TryAllNavigationPolicy" 

Length of output: 130

Copy link

sonarcloud bot commented Nov 13, 2024

@kodiakhq kodiakhq bot merged commit 281be28 into acts-project:main Nov 13, 2024
44 checks passed
Rosie-Hasan pushed a commit to Rosie-Hasan/acts that referenced this pull request Nov 13, 2024
I previously neglected to include the overload with the configuration in the python bindings. This PR does that and also includes test coverage for this behavior.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
	- Introduced a new method to the navigation policy factory for adding `TryAllNavigationPolicy` with configuration parameters.
	- Added Python bindings for the `TryAllNavigationPolicy::Config` class.

- **Bug Fixes**
	- Adjusted constructor parameter order for `TryAllNavigationPolicy`, enhancing clarity and usability.

- **Tests**
	- Added a new test function to validate the addition of `TryAllNavigationPolicy` with specific configuration options.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coderabbit Component - Core Affects the Core module Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants