-
Notifications
You must be signed in to change notification settings - Fork 3
Fix threads per core when submitting to queue #618
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
WalkthroughThe changes update the handling of the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant QueueSpawner
participant ResourceDict
Caller->>QueueSpawner: Call spawn function
QueueSpawner->>ResourceDict: Check if "threads_per_core" exists
alt "threads_per_core" exists
QueueSpawner->>ResourceDict: Multiply "cores" by threads_per_core value
QueueSpawner->>ResourceDict: Remove "threads_per_core" from resource_dict
else Not found
QueueSpawner->>ResourceDict: Proceed with original logic
end
Note right of QueueSpawner: Removal from unsupported_keys is omitted
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #618 +/- ##
=======================================
Coverage 96.40% 96.41%
=======================================
Files 28 28
Lines 1252 1255 +3
=======================================
+ Hits 1207 1210 +3
Misses 45 45 ☔ 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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
executorlib/cache/queue_spawner.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (15)
- GitHub Check: unittest_openmpi (macos-latest, 3.13)
- GitHub Check: notebooks
- GitHub Check: unittest_flux_mpich
- 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: unittest_openmpi (ubuntu-latest, 3.11)
- GitHub Check: unittest_old
- GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
- GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
- GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
- GitHub Check: unittest_mpich (ubuntu-latest, 3.11)
- GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
- GitHub Check: unittest_win
- GitHub Check: unittest_mpich (macos-latest, 3.13)
- GitHub Check: unittest_flux_openmpi
| if "threads_per_core" in resource_dict: | ||
| resource_dict["cores"] *= resource_dict["threads_per_core"] | ||
| del resource_dict["threads_per_core"] |
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.
🛠️ Refactor suggestion
Add validation to prevent potential errors.
The new code handles "threads_per_core" by multiplying it with "cores", but it's missing validation that could prevent runtime errors:
- There's no check if "cores" exists in the dictionary before attempting to multiply
- No validation that both values are numeric
- No protection against "threads_per_core" being zero
if "threads_per_core" in resource_dict:
- resource_dict["cores"] *= resource_dict["threads_per_core"]
- del resource_dict["threads_per_core"]
+ threads = resource_dict.pop("threads_per_core")
+ if "cores" in resource_dict and threads:
+ resource_dict["cores"] *= threads
+ elif "cores" not in resource_dict and threads:
+ # Handle case where cores isn't defined but threads_per_core is
+ resource_dict["cores"] = threads📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if "threads_per_core" in resource_dict: | |
| resource_dict["cores"] *= resource_dict["threads_per_core"] | |
| del resource_dict["threads_per_core"] | |
| if "threads_per_core" in resource_dict: | |
| threads = resource_dict.pop("threads_per_core") | |
| if "cores" in resource_dict and threads: | |
| resource_dict["cores"] *= threads | |
| elif "cores" not in resource_dict and threads: | |
| # Handle case where cores isn't defined but threads_per_core is | |
| resource_dict["cores"] = threads |
Summary by CodeRabbit