-
Notifications
You must be signed in to change notification settings - Fork 3
map(): Evaluate generator within with-statement #812
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
Conversation
WalkthroughTests were updated to eagerly materialize map results with list(p.map(...)) and to compare the resulting lists directly in assertions. No production code or public APIs were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #812 +/- ##
=======================================
Coverage 97.76% 97.76%
=======================================
Files 32 32
Lines 1479 1479
=======================================
Hits 1446 1446
Misses 33 33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/test_fluxjobexecutor.py (2)
125-129: Optional: make log-file cleanup resilient to assertion failures.If an assertion fails, the remove(...) calls won’t run. Consider registering cleanup handlers instead:
# near file_stdout/file_stderr definitions self.addCleanup(lambda: os.path.exists(file_stdout) and os.remove(file_stdout)) self.addCleanup(lambda: os.path.exists(file_stderr) and os.remove(file_stderr))
145-149: Same optional cleanup robustness here.Use addCleanup (or a try/finally) so log files are removed even if assertions fail.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
tests/test_fluxjobexecutor.py(3 hunks)tests/test_fluxpythonspawner.py(1 hunks)tests/test_mpiexecspawner.py(2 hunks)tests/test_singlenodeexecutor_mpi.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
tests/test_fluxpythonspawner.py (1)
tests/test_fluxjobexecutor.py (1)
mpi_funct(23-28)
tests/test_mpiexecspawner.py (1)
tests/test_fluxjobexecutor.py (1)
mpi_funct(23-28)
tests/test_fluxjobexecutor.py (1)
tests/test_fluxpythonspawner.py (2)
mpi_funct(26-31)calc(22-23)
⏰ 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). (16)
- GitHub Check: notebooks_integration
- GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
- GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
- GitHub Check: notebooks
- GitHub Check: unittest_openmpi (ubuntu-24.04-arm, 3.13)
- GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
- GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
- GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
- GitHub Check: unittest_openmpi (macos-latest, 3.13)
- GitHub Check: unittest_mpich (macos-latest, 3.13)
- GitHub Check: unittest_old
- GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
- GitHub Check: unittest_slurm_mpich
- GitHub Check: unittest_mpich (ubuntu-22.04-arm, 3.13)
- GitHub Check: unittest_win
- GitHub Check: unittest_flux_openmpi
🔇 Additional comments (6)
tests/test_fluxpythonspawner.py (1)
102-105: Eager materialization inside the context is correct.Consuming the map iterator with list(...) before the with-block exits ensures resources from FluxPythonSpawner remain valid during iteration. Good fix.
tests/test_singlenodeexecutor_mpi.py (1)
122-126: Good change: evaluate map within the executor context.Materializing results before teardown avoids using a closed pool/spawner.
tests/test_fluxjobexecutor.py (1)
107-111: Solid: list(...) ensures generator is evaluated while FluxJobExecutor is alive.tests/test_mpiexecspawner.py (3)
326-327: Correct: consume map results within the with-statement.Prevents iterating after the scheduler has shut down.
433-437: Good: early materialization for the MPI map case as well.
433-437: Approve changes — no remaining lazy map usages detected
Sanity check script found no.map(…)calls outside oflist()/tuple()wrappers in the test suite.
Summary by CodeRabbit