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

feat: Allow compiling examples without ROOT #4090

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

benjaminhuth
Copy link
Member

@benjaminhuth benjaminhuth commented Feb 14, 2025

First step towards pip install acts?

--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

  • Use a conventional commits prefix: quick summary
    • We mostly use feat, fix, refactor, docs, chore and build types.
  • A milestone will be assigned by one of the maintainers

Summary by CodeRabbit

  • New Features

    • Introduced a configurable build option that enables advanced ROOT I/O components.
    • Enhanced Python integration with new input and output capabilities when ROOT I/O is activated.
  • Refactor

    • Updated module inclusion to conditionally incorporate ROOT functionalities, modernizing input handling and streamlining dependencies.
  • Documentation

    • Revised build instructions to document the new option for enabling ROOT I/O–based modules.

Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

Hmm, changes made they have been. A new CMake option for ROOT I/O is introduced, it is. Conditional logic in CMake files now controls the inclusion of ROOT dependencies and example subdirectories. In Python bindings, adjustments are done—legacy ROOT readers and writers removed, new functions and interface for track parameter lookup added. Various source files in the Examples/Io and Examples/Python directories updated have been. Configurability increased, it is.

Changes

File(s) Change Summary
CMakeLists.txt, CMakePresets.json, docs/.../getting_started.md New option ACTS_BUILD_EXAMPLES_ROOT added; configuration updated to include ROOT I/O examples conditionally.
Examples/Io/CMakeLists.txt, Examples/Io/Root/CMakeLists.txt Conditional inclusion of the Root subdirectory introduced; compile definition for ActsExamplesIoRoot added.
Examples/Python/CMakeLists.txt Python bindings configuration updated to conditionally link ActsExamplesIoRoot and select source files based on ROOT option.
Examples/Python/src/Input.cpp, Examples/Python/src/RootInput.cpp Legacy ROOT reader declarations removed; new interface ITrackParamsLookupReader and addRootInput function added.
Examples/Python/src/Output.cpp, Examples/Python/src/RootOutput.cpp Old ROOT writer bindings removed; new pybind11 bindings for IMaterialWriter and ITrackParamsLookupWriter, and new addRootOutput function added.
Examples/Python/src/Material.cpp, Examples/Python/src/ModuleEntry.cpp, Examples/Python/src/RootStub.cpp Conditional header inclusion added in Material; new functions added in ModuleEntry and stub implementations provided for ROOT I/O.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as CMake
    participant P as Python Bindings
    participant R as ROOT Packages

    U->>C: Set ACTS_BUILD_EXAMPLES_ROOT (ON/OFF)
    alt ROOT Enabled
        C->>R: Find and verify ROOT packages
        C->>C: Include Root subdirectory and apply compile definitions
        C->>P: Link ActsExamplesIoRoot and select ROOT input/output sources
        P->>P: Register addRootInput and addRootOutput functions with reader/writer bindings
    else ROOT Disabled
        C->>P: Select stub implementations for ROOT support
    end
Loading

Suggested labels

automerge

Suggested reviewers

  • andiwand

Poem

In code’s galaxy, a new light is born,
Conditional paths through the build, we now adorn.
Legacy shadows fade, replaced by functions so bright,
With ROOT or without, our project feels right.
Merge the changes, we must—with joy and might.
Hmm, celebrate these shifts, we do tonight!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@benjaminhuth benjaminhuth added this to the next milestone Feb 14, 2025
@github-actions github-actions bot added Component - Examples Affects the Examples module Component - Documentation Affects the documentation labels Feb 14, 2025
Copy link

📊: Physics performance monitoring for bdfff81

Full contents

physmon summary

Copy link

@benjaminhuth benjaminhuth marked this pull request as ready for review February 14, 2025 14:46
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: 1

🧹 Nitpick comments (5)
Examples/Python/src/Input.cpp (1)

70-73: A new class binding, introduced you have.
Implementation detail for the ITrackParamsLookupReader is minimal here, hmmm. Large expansions possible in the future, yes. Document or extend it, you could.

Examples/Python/src/RootOutput.cpp (2)

152-210: Wise it is to separate measurement logic, root or otherwise.
Two distinct classes for measurement and material writing, you have. Straightforward they seem, but thorough testing with real geometry data, ensure.


212-254: Root-based writer macros, many they be.
Comprehensive coverage of use cases, indeed. Maintain consistency in file naming and paths, you should.

Examples/Python/src/RootInput.cpp (1)

28-60: Function addRootInput, to read data in.
A clear approach, using macros for each specialized reader. Verify naming for clarity, you should, especially with many overlapping parameters.

Examples/Io/Root/CMakeLists.txt (1)

50-50: Document the purpose of this compile definition, you should!

While correct the definition is, its purpose and usage in the codebase, unclear they remain.

Add a comment explaining the purpose of ACTS_EXAMPLES_WITH_ROOT:

+# Define ACTS_EXAMPLES_WITH_ROOT to enable conditional compilation of ROOT-dependent code
 target_compile_definitions(ActsExamplesIoRoot PUBLIC ACTS_EXAMPLES_WITH_ROOT)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4606c6 and bdfff81.

📒 Files selected for processing (13)
  • CMakeLists.txt (2 hunks)
  • CMakePresets.json (1 hunks)
  • Examples/Io/CMakeLists.txt (1 hunks)
  • Examples/Io/Root/CMakeLists.txt (1 hunks)
  • Examples/Python/CMakeLists.txt (1 hunks)
  • Examples/Python/src/Input.cpp (2 hunks)
  • Examples/Python/src/Material.cpp (3 hunks)
  • Examples/Python/src/ModuleEntry.cpp (2 hunks)
  • Examples/Python/src/Output.cpp (1 hunks)
  • Examples/Python/src/RootInput.cpp (1 hunks)
  • Examples/Python/src/RootOutput.cpp (1 hunks)
  • Examples/Python/src/RootStub.cpp (1 hunks)
  • docs/getting_started.md (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • Examples/Python/src/Material.cpp
  • Examples/Python/src/RootStub.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: merge-sentinel
🔇 Additional comments (14)
Examples/Python/src/Input.cpp (1)

20-20: A new include, necessary it is.
Include line matches the new interface usage, correct it appears.

Examples/Python/src/RootOutput.cpp (3)

9-30: Galore of includes, you have.
All relevant headers, correct they seem. Ensure compilation flags remain consistent, you must.


53-74: Function addRootOutput, introduced it is.
Central binding method it serves, grouping many writers in one place, hmm. Good design pattern for modularizing I/O, it appears.


76-150: Writers, declared in plenty they are.
Macros yield clarity, yes, though verifying correctness with actual data flow, necessary it is.

Examples/Python/src/RootInput.cpp (2)

9-16: ROOT-based headers, included.
Needed for bridging the I/O functionalities, hmmm. All correct they look.


61-65: Conditional compilation, you have.
WITH_GEOMODEL_PLUGIN usage is wise, but test coverage ensure for both on and off states, hmmm.

Examples/Python/src/ModuleEntry.cpp (2)

59-60: Clean and orderly, these additions are!

Following the established pattern of module initialization functions, these declarations do. Approve them, I do.


150-151: Wise placement of initialization calls, this is!

At the end of plugin initializations, these new calls reside. A natural position for ROOT-related functionality, it is.

Examples/Python/src/Output.cpp (1)

211-216: Well-crafted bindings, these are!

Using shared_ptr wisely, you do. Following pybind11 best practices, this implementation does.

Examples/Io/CMakeLists.txt (1)

6-6: Consistent with the Force, this CMake change is!

Like its siblings EDM4hep and HepMC3, conditional inclusion for Root now exists. A harmonious balance in the build system, this brings.

Examples/Python/CMakeLists.txt (1)

86-94: Well structured, this conditional compilation is!

Follow the established patterns it does, hmm. When ROOT not present, stub implementation it provides. Clean and consistent with other similar conditionals in the file, this approach is.

CMakeLists.txt (2)

106-106: Wisely placed, this new option is.

Among other example-related options it sits, following the established pattern it does.


511-521: Proper ROOT dependency handling, this is.

When ACTS_BUILD_EXAMPLES_ROOT enabled is, required ROOT components it finds. Compatibility it checks, hmm. Good practices these are.

docs/getting_started.md (1)

303-303: Well documented, this new option is.

In the build options table, properly placed it is. Format it follows, description clear it provides.

@@ -17,6 +17,7 @@
"ACTS_BUILD_PLUGIN_LEGACY": "ON",
"ACTS_BUILD_EXAMPLES_DD4HEP": "ON",
"ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS": "ON",
"ACTS_BUILD_EXAMPLES_ROOT": "ON",
Copy link

@coderabbitai coderabbitai bot Feb 14, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent default value with CMakeLists.txt, this is.

In CMakeLists.txt, default value OFF it is, but here ON we see. Confusion this may cause, when different build methods users try. Align these defaults we should, hmm.

Copy link
Member Author

Choose a reason for hiding this comment

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

The convention is, that in the CmakeLists.txt, all options are off. Therefore, this aligns with our design.

Copy link

Choose a reason for hiding this comment

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

@benjaminhuth Understand the wisdom of your ways, I do. Clear it is now - CMakeLists.txt defaults to OFF by design, while presets may override, hmm yes.

(_/)

(^.^) ponders deeply about CMake wisdom


✏️ Learnings added
Learnt from: benjaminhuth
PR: acts-project/acts#4090
File: CMakePresets.json:20-20
Timestamp: 2025-02-14T22:15:51.190Z
Learning: In the ACTS project, CMake options in CMakeLists.txt are intentionally set to OFF by default, while CMakePresets.json can override these defaults with ON values as per the project's design convention.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

#include "ActsExamples/MaterialMapping/CoreMaterialMapping.hpp"
#include "ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp"
#include "ActsExamples/MaterialMapping/MaterialMapping.hpp"
#include "ActsExamples/MaterialMapping/MaterialValidation.hpp"

#ifdef ACTS_EXAMPLES_WITH_ROOT
Copy link
Member

Choose a reason for hiding this comment

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

I think we should try to find a way to do this without a preprocessor define. Can we handle this in CMake somehow?
This would probably need to move to the ROOT IO folder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah probably we should put this to RootInput.cpp and avoid the preprocessor ifdef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Documentation Affects the documentation Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants