Conversation
WalkthroughThis PR updates CI/CD configuration to support Python 3.11 with legacy OpenMC installation, bumps the f4enix dependency to version 0.19.0, refactors an import path for consistency, enhances RMODE 0 handling logic with improved file formatting, and adds comprehensive test coverage with three new MCNP input test files and a corresponding test function. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/jade/helper/aux_functions.py (1)
109-109:⚠️ Potential issue | 🔴 CriticalPrevent empty-file crash and robustly detect existing RMODE cards.
At Line 127,
lines[-1]can crash on empty/all-blank files. Also, Line 123 uses a strictmatchpattern that can miss indented or multi-spaceRMODE 0lines and append duplicates.🔧 Proposed fix
-def add_rmode0(path: PathLike) -> None: +def add_rmode0(path: PathLike) -> None: @@ - pattern = re.compile(r"rmode 0", re.IGNORECASE) + pattern = re.compile(r"^\s*rmode\s+0(?:\s|$)", re.IGNORECASE) @@ - for line in lines: - if pattern.match(line): + for line in lines: + if pattern.match(line): found = True f.write(line) if not found: - if not lines[-1].endswith("\n"): + if lines and not lines[-1].endswith("\n"): f.write("\n") f.write("RMODE 0\n")Also applies to: 117-119, 123-123, 127-128
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/jade/helper/aux_functions.py` at line 109, The code currently compiles pattern = re.compile(r"rmode 0", re.IGNORECASE) and uses lines[-1] and re.match which can crash on empty/all-blank files and miss indented or multi-space "RMODE 0" lines, causing duplicates; update the regex to r"^\s*rmode\s+0\b" (case-insensitive) and replace re.match with pattern.search, check existence with any(pattern.search(line) for line in lines) to avoid duplicates, and find or append to the last non-blank line instead of lines[-1] (handle empty files by initializing lines to [''] or appending to an empty list safely), ensuring any appended RMODE line uses consistent newline handling.
🧹 Nitpick comments (2)
tests/helper/test_auxiliary_func.py (1)
58-60: Assert RMODE uniqueness, not only presence.Current check passes even if duplicate
RMODE 0cards are added. Strengthen this test to assert exactly one RMODE card per file.✅ Example stronger assertion
- assert "RMODE" in inp.other_data.keys(), ( - f"RMODE card not found in the input file {file}" - ) + text = dst.joinpath(file).read_text() + rmode_count = sum( + 1 for line in text.splitlines() + if line.strip().upper() == "RMODE 0" + ) + assert rmode_count == 1, f"Expected one RMODE 0 in {file}, found {rmode_count}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/helper/test_auxiliary_func.py` around lines 58 - 60, The test currently only checks presence of the "RMODE" key via inp.other_data.keys(); change it to assert there is exactly one RMODE card by validating the count of RMODE entries (e.g., len(inp.other_data.get("RMODE", [])) == 1) and keep the existing failure message (referencing file) so the test fails if there are zero or multiple RMODE cards; update the assertion that currently references inp.other_data and "RMODE" to check for exact uniqueness rather than mere presence..github/workflows/pytest.yml (1)
65-67: Use distinct step names for legacy OpenMC installs.Both legacy install steps share the same name, which makes job logs harder to read/debug. Consider naming them by Python version.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/pytest.yml around lines 65 - 67, The two legacy install steps both use the name "Install openmc (legacy)" which makes logs ambiguous; update the step names to be unique and include the Python version (e.g., "Install openmc (legacy, py3.11)") for the step with condition matrix.python-version == '3.11' and likewise for the other legacy step (reference the step name "Install openmc (legacy)" in your diff), ensuring each step name clearly identifies its Python version so job logs are readable and distinguishable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/jade/helper/aux_functions.py`:
- Line 109: The code currently compiles pattern = re.compile(r"rmode 0",
re.IGNORECASE) and uses lines[-1] and re.match which can crash on
empty/all-blank files and miss indented or multi-space "RMODE 0" lines, causing
duplicates; update the regex to r"^\s*rmode\s+0\b" (case-insensitive) and
replace re.match with pattern.search, check existence with
any(pattern.search(line) for line in lines) to avoid duplicates, and find or
append to the last non-blank line instead of lines[-1] (handle empty files by
initializing lines to [''] or appending to an empty list safely), ensuring any
appended RMODE line uses consistent newline handling.
---
Nitpick comments:
In @.github/workflows/pytest.yml:
- Around line 65-67: The two legacy install steps both use the name "Install
openmc (legacy)" which makes logs ambiguous; update the step names to be unique
and include the Python version (e.g., "Install openmc (legacy, py3.11)") for the
step with condition matrix.python-version == '3.11' and likewise for the other
legacy step (reference the step name "Install openmc (legacy)" in your diff),
ensuring each step name clearly identifies its Python version so job logs are
readable and distinguishable.
In `@tests/helper/test_auxiliary_func.py`:
- Around line 58-60: The test currently only checks presence of the "RMODE" key
via inp.other_data.keys(); change it to assert there is exactly one RMODE card
by validating the count of RMODE entries (e.g., len(inp.other_data.get("RMODE",
[])) == 1) and keep the existing failure message (referencing file) so the test
fails if there are zero or multiple RMODE cards; update the assertion that
currently references inp.other_data and "RMODE" to check for exact uniqueness
rather than mere presence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: adf22449-3b41-4a1d-95d8-d7b6714b26d3
📒 Files selected for processing (10)
.github/workflows/pytest.ymlpyproject.tomlsrc/jade/helper/aux_functions.pysrc/jade/run/input.pytests/helper/res/__init__.pytests/helper/res/rmode/__init__.pytests/helper/res/rmode/sphere_more_spaces.itests/helper/res/rmode/sphere_no_spaces.itests/helper/res/rmode/sphere_rmode.itests/helper/test_auxiliary_func.py
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
The add_rmode0 function is key to deploy JADE on clusters where D1SUNED is installed. There were a bunch of edge cases that were not covered by the logic of the functions. These are covered now. To be reviewed after #484
Summary by CodeRabbit
Dependencies
Bug Fixes
Tests
Chores