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: Use RootTracksummaryWriter without truth information #3886

Conversation

benjaminhuth
Copy link
Member

@benjaminhuth benjaminhuth commented Nov 21, 2024

Since some people start to do tests within the examples framework with real data, we should extend our algorithms/writers to not require these information. This PR does the relevant changes for the RootTracksummaryWriter.

--- 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

    • Enhanced flexibility in handling optional input parameters for the RootTrackSummaryWriter, allowing the program to operate without mandatory input collections.
    • Improved robustness in data handling processes, ensuring the program continues executing even with incomplete data.
  • Bug Fixes

    • Updated error handling to prevent exceptions when input collections are not populated.
  • Tests

    • Introduced new tests to validate the functionality of the RootTrackSummaryWriter and integrated it into existing testing frameworks for comprehensive coverage.

@benjaminhuth benjaminhuth added this to the next milestone Nov 21, 2024
Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

Changes made to the RootTrackSummaryWriter class enhance its flexibility and robustness. The Config struct comments were updated to indicate optional inputs. The constructor and writeT method were modified to improve initialization and error handling, allowing the program to proceed without exceptions for missing inputs. A new test was introduced to validate the functionality of the RootTrackSummaryWriter, ensuring it integrates well with existing tests and adheres to the expected interface.

Changes

File Change Summary
Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryWriter.hpp Updated comments in Config struct for inputParticles and inputTrackParticleMatching to indicate they are optional.
Examples/Io/Root/src/RootTrackSummaryWriter.cpp Constructor logic updated to use maybeInitialize for input checks. Modified writeT to handle empty input collections with static containers. Enhanced handling of track states and measurements.
Examples/Python/tests/test_writer.py Added test_root_tracksummary_writer to validate RootTrackSummaryWriter. Updated test_root_writer_interface to include it in parameterized tests.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant Config
    participant RootTrackSummaryWriter
    participant InputCollections
    participant OutputFiles

    User->>Config: Create configuration
    User->>RootTrackSummaryWriter: Initialize with config
    RootTrackSummaryWriter->>InputCollections: Check for input particles
    alt Input particles available
        RootTrackSummaryWriter->>InputCollections: Process input particles
    else No input particles
        RootTrackSummaryWriter->>InputCollections: Use emptyParticles
    end
    RootTrackSummaryWriter->>OutputFiles: Write output files
    OutputFiles-->>User: Return generated files

In the realm of code, changes unfold,
Flexibility and strength, a story told.
Comments updated, inputs now clear,
Robustness enhanced, let’s give a cheer!
Tests now included, validation in sight,
A brighter future, our code takes flight!
🌟✨


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 the Component - Examples Affects the Examples module label Nov 21, 2024
Copy link

github-actions bot commented Nov 21, 2024

📊: Physics performance monitoring for b1bdb7c

Full contents

physmon summary

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@andiwand
Copy link
Contributor

Overall I wonder if it might be easier to just have empty truth information in case these entries in the whiteboard are not present. I think not having any truth should act similarly to not matching to truth?

I would also like to avoid special casing in all directions so we can make data workflows work as this seems really not the goal of our design.

Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

Looks good thank you! 🚀

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

🧹 Outside diff range and nitpick comments (3)
Examples/Python/tests/test_writer.py (3)

206-220: Strengthen the test assertions, we must!

Missing assertions for the first phase of testing, I observe. Verify the successful execution of truth tracking, we should.

Add assertions to verify the truth tracking execution:

    s=s,
)
+ assert "tracks" in s.store  # Verify tracks were created
+ assert "measurement_particles_map" in s.store  # Verify truth mapping exists

222-230: Clear configuration, but magic string lurks in shadows!

Good configuration of writer without truth information, but hardcoded collection name "tracks" I see.

Consider defining collection name as constant:

+ TRACKS_COLLECTION = "tracks"
  s.addWriter(
      conf_const(
          RootTrackSummaryWriter,
          level=acts.logging.INFO,
-         inputTracks="tracks",
+         inputTracks=TRACKS_COLLECTION,
          filePath=str(tmp_path / "track_summary_kf_no_truth.root"),
      )
  )

200-235: Test cleanup, missing it is!

Resources properly released, they must be. Cleanup after test execution, we should add.

Add cleanup using pytest fixture:

@pytest.fixture(autouse=True)
def cleanup(tmp_path):
    yield
    # Clean up root files after test
    for file in tmp_path.glob("*.root"):
        file.unlink()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 622902b and b62cc53.

📒 Files selected for processing (3)
  • Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryWriter.hpp (1 hunks)
  • Examples/Io/Root/src/RootTrackSummaryWriter.cpp (3 hunks)
  • Examples/Python/tests/test_writer.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryWriter.hpp
🔇 Additional comments (4)
Examples/Python/tests/test_writer.py (2)

200-201: Appropriate test marker and function signature, hmm, yes!

Well-placed, the @pytest.mark.root decorator is. Clear and descriptive, the test function name becomes.


202-204: Proper test setup, I sense!

Wisely chosen, the test components are:

  • Generic detector for simplicity
  • Constant magnetic field for predictability
  • Sequential processing for deterministic results
Examples/Io/Root/src/RootTrackSummaryWriter.cpp (2)

63-65: Improved initialization, you have.

Replacing explicit checks with maybeInitialize, flexibility it brings.


218-227: Handle missing truth information, you do.

By using empty collections when uninitialized, robustness you ensure.

@kodiakhq kodiakhq bot merged commit 832b327 into acts-project:main Nov 26, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaks Athena build This PR breaks the Athena build Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants