Skip to content

Conversation

@PhilipDeegan
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Warning

Rate limit exceeded

@PhilipDeegan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between bb9610b and a6e5c70.

📒 Files selected for processing (1)
  • tests/simulator/test_exceptions.py
📝 Walkthrough

Walkthrough

Added same-level neighbor utilities and domain-overlap checks; applied a const qualifier to a level parameter; wrapped hybrid level initialization overlap validation in try/catch and integrated MPI-aware error throwing; extended DictionaryException with an id() accessor and updated Simulator to catch DictionaryException and trigger emergency dumps across all levels when matching configured IDs.

Changes

Cohort / File(s) Summary
Domain-overlap utilities & AMR helpers
src/amr/resources_manager/amr_utils.hpp
Added getSameLevelNeighbors(...) and two noDomainOverlapsOn(...) overloads to detect/throw on same-level domain overlaps; replaced local HierarchyNeighbors construction with the new helper; minor include and loop-increment adjustments.
Hybrid level initializer
src/amr/level_initializer/hybrid_level_initializer.hpp
Changed isRootLevel signature to int const levelNumber; added try/catch around post-initialization call to amr::noDomainOverlapsOn(*hierarchy, levelNumber) and log/throw on exceptions or MPI errors.
Core errors API
src/core/errors.hpp
Added #include <stdexcept> and new std::string DictionaryException::id() const accessor that returns the stored "ID" or throws std::runtime_error if missing.
Simulator exception handling / dumps
src/simulator/simulator.hpp
Use cppdict::get_value(..., "allow_emergency_dumps", false) for option retrieval; added catch (core::DictionaryException&) to initialization, updated handle_dictionary_exception to match against a list of exception IDs and dump all levels via dump manager when matched.
Tests / diagnostics usage
tests/simulator/test_exceptions.py
Added Run usage and a FluidDiagnostics invocation; enabled "allow_emergency_dumps": True in diag options and added a post-exception plotting call to exercise emergency diagnostics.

Sequence Diagram(s)

sequenceDiagram
  actor User
  Participant Simulator
  Participant HybridInitializer
  Participant AMRUtils
  Participant DictionaryException
  Participant DumpManager
  Participant Logger

  User->>Simulator: start initialize()
  Simulator->>HybridInitializer: initialize(hierarchy, levelNumber)
  HybridInitializer->>AMRUtils: noDomainOverlapsOn(hierarchy, levelNumber)
  AMRUtils-->>HybridInitializer: throws DictionaryException (on overlap) / returns OK
  alt overlap/exception
    HybridInitializer->>Simulator: propagate exception
    Simulator->>DictionaryException: catch
    Simulator->>DumpManager: handle_dictionary_exception -> dump_level (all levels)
    DumpManager->>Logger: log dumps
  else no overlap
    HybridInitializer-->>Simulator: initialization complete
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • nicolasaunai
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning No description was provided by the author; the pull request description is empty. Add a description explaining the purpose of domain overlap checks, what issues they address, and how they integrate with the simulator's error handling flow.
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: adding domain overlap checks across multiple files (amr_utils.hpp, hybrid_level_initializer.hpp, and integration into simulator.hpp), which is the core purpose of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@PhilipDeegan PhilipDeegan force-pushed the catastroph branch 3 times, most recently from 2f6d1eb to 099c89d Compare January 15, 2026 17:04
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

🤖 Fix all issues with AI agents
In `@tests/simulator/test_exceptions.py`:
- Line 101: The test currently calls Run(out).GetN(0, "protons").plot(), which
can fail in headless CI; either remove the .plot() call and assert the data
exists by calling Run(out).GetN(0, "protons") (or inspecting its contents), or
set a non-interactive matplotlib backend (e.g., call matplotlib.use('Agg') at
the top of the test module before any plotting imports) to ensure .plot() won't
require a display; update the test to use one of these approaches and keep the
check focused on GetN.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9de39e5 and bb9610b.

📒 Files selected for processing (5)
  • src/amr/level_initializer/hybrid_level_initializer.hpp
  • src/amr/resources_manager/amr_utils.hpp
  • src/core/errors.hpp
  • src/simulator/simulator.hpp
  • tests/simulator/test_exceptions.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/core/errors.hpp
  • src/simulator/simulator.hpp
🧰 Additional context used
📓 Path-based instructions (1)
**/*.hpp

⚙️ CodeRabbit configuration file

Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

Files:

  • src/amr/level_initializer/hybrid_level_initializer.hpp
  • src/amr/resources_manager/amr_utils.hpp
🧠 Learnings (2)
📓 Common learnings
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-07-26T22:04:34.160Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-10-09T08:32:15.667Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 1068
File: src/amr/data/field/coarsening/electric_field_coarsener.hpp:1-2
Timestamp: 2025-09-17T13:35:11.533Z
Learning: PhilipDeegan prefers header guard names that include the full directory path structure, following the pattern PHARE_[PATH_WITH_UNDERSCORES]_HPP. For example, a file at src/amr/data/field/coarsening/electric_field_coarsener.hpp should use PHARE_AMR_DATA_FIELD_COARSENING_ELECTRIC_FIELD_COARSENER_HPP as the header guard.
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 888
File: src/hdf5/detail/h5/h5_file.hpp:78-79
Timestamp: 2024-10-09T08:32:15.667Z
Learning: Avoid commenting on draft PRs for the user PhilipDeegan.
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 888
File: src/hdf5/detail/h5/h5_file.hpp:78-79
Timestamp: 2024-09-05T17:02:58.784Z
Learning: Avoid commenting on draft PRs for the user PhilipDeegan.
📚 Learning: 2025-11-10T09:37:57.021Z
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 1084
File: src/diagnostic/diagnostic_model_view.hpp:219-221
Timestamp: 2025-11-10T09:37:57.021Z
Learning: In PHARE, temporary fields like tmpField_, tmpVec_, and tmpTensor_ in src/diagnostic/diagnostic_model_view.hpp use a name-based resource allocation pattern. Fields with names "PHARE_sumField", "PHARE_sumVec", and "PHARE_sumTensor" are allocated globally elsewhere in the resources manager (e.g., in src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp), and components reference the same storage through identically-named field objects. These do not require local allocation via rm.enumerate().

Applied to files:

  • src/amr/level_initializer/hybrid_level_initializer.hpp
🧬 Code graph analysis (2)
src/amr/level_initializer/hybrid_level_initializer.hpp (2)
src/amr/resources_manager/amr_utils.hpp (4)
  • noDomainOverlapsOn (210-218)
  • noDomainOverlapsOn (210-210)
  • noDomainOverlapsOn (220-224)
  • noDomainOverlapsOn (220-220)
src/core/utilities/types.hpp (4)
  • any (359-363)
  • any (359-360)
  • any (382-385)
  • any (382-382)
tests/simulator/test_exceptions.py (3)
pyphare/pyphare/simulator/simulator.py (1)
  • run (200-238)
pyphare/pyphare/pharesee/run/run.py (2)
  • Run (35-289)
  • GetN (120-122)
pyphare/pyphare/pharein/diagnostics.py (1)
  • FluidDiagnostics (292-304)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: build (macos-14)
  • GitHub Check: Analyze (python)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: Analyze (cpp)
🔇 Additional comments (12)
tests/simulator/test_exceptions.py (3)

6-6: LGTM!

Import correctly added for the Run class used later in the test.


64-67: LGTM!

The FluidDiagnostics with empty write_timestamps is correctly set up to enable emergency dumps without writing during normal execution. The comment clarifies the intent.


80-80: LGTM!

The allow_emergency_dumps option correctly enables the emergency dump feature that this test validates.

src/amr/resources_manager/amr_utils.hpp (5)

19-19: LGTM!

The <stdexcept> include is correctly added to support the std::runtime_error usage in noDomainOverlapsOn.


200-208: LGTM!

Clean utility function that encapsulates the same-level neighbor query. The NO_DISCARD attribute is appropriate since discarding the result would indicate a logic error.


210-224: LGTM!

The domain overlap detection logic is well-structured:

  • Clear error message identifies the problematic level
  • The check is O(patches × neighbors) which is acceptable for validation
  • The overloaded version for all levels correctly delegates to the single-level version

238-238: LGTM!

Good refactoring to use the new getSameLevelNeighbors utility, eliminating code duplication.


274-275: LGTM!

Minor style improvement using pre-increment, which is idiomatic for loop counters in C++.

src/amr/level_initializer/hybrid_level_initializer.hpp (4)

4-20: LGTM!

Include reorganization is clean and properly structured:

  • Core headers grouped together
  • AMR headers grouped together
  • <exception> header added for std::exception usage in catch block

43-43: LGTM!

Adding const to the parameter clarifies intent and prevents accidental modification.


185-185: No concerns.

Formatting change only.


86-96: The exception handling is correct; no changes needed.

PHARE_LOG_ERROR automatically registers the error with core::Errors::instance() by calling its log() method, which adds the error to the internal map. The subsequent core::mpi::any(core::Errors::instance().any()) check will correctly detect this logged error and throw DictionaryException. The exception is not swallowed.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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