-
Notifications
You must be signed in to change notification settings - Fork 59
Refactor log messages for clarity and consistency #561
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
base: master
Are you sure you want to change the base?
Conversation
- add option: "strategy": {"customized_script_header_template_file": ""},
- add option: `sge_pe_name`
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Update pbs.py
for more information, see https://pre-commit.ci
This reverts commit c8b0198.
fetch origin master
for more information, see https://pre-commit.ci
Removed redundant 'debug:' and 'info:' prefixes from log messages and improved formatting for better readability. Also removed unused exception variable in SSHSession and simplified error handling.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #561 +/- ##
===========================================
- Coverage 60.45% 47.64% -12.81%
===========================================
Files 39 39
Lines 3912 3912
===========================================
- Hits 2365 1864 -501
- Misses 1547 2048 +501 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughRemoved unused exception-variable bindings in SSH key loading and standardized log message contents by removing redundant "debug:"/"info:" prefixes and tightening message spacing/formatting; no functional logic changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
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)
dpdispatcher/utils/dpcloudserver/client.py (1)
182-184: Inconsistent leading space in log message.The log message on line 183 has a leading space before "upload:", while the similar changes on lines 144 and 152 don't have leading spaces. Consider removing it for consistency:
- f" upload: oss_task_zip:{oss_task_zip}; zip_task_file:{zip_task_file}" + f"upload: oss_task_zip:{oss_task_zip}; zip_task_file:{zip_task_file}"dpdispatcher/submission.py (1)
861-863: Use explicit conversion flag per Ruff recommendation.Instead of using
repr()function, use the!rconversion flag in the f-string for better readability and to satisfy the Ruff linter (RUF010).- f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}" + f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {self.job_state!r}"Based on learnings, ... As per coding guidelines, ...
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
dpdispatcher/contexts/ssh_context.py(2 hunks)dpdispatcher/submission.py(6 hunks)dpdispatcher/utils/dpcloudserver/client.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Always add type hints in all Python code
Ensure code remains compatible with Python 3.7+ (avoid syntax/features newer than 3.7)
Use Ruff (via pre-commit) for linting and formatting
Files:
dpdispatcher/contexts/ssh_context.pydpdispatcher/utils/dpcloudserver/client.pydpdispatcher/submission.py
🧬 Code graph analysis (1)
dpdispatcher/submission.py (1)
dpdispatcher/utils/job_status.py (1)
JobStatus(4-11)
🪛 Ruff (0.14.8)
dpdispatcher/submission.py
862-862: Use explicit conversion flag
Replace with conversion flag
(RUF010)
⏰ 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). (4)
- GitHub Check: pass
- GitHub Check: Agent
- GitHub Check: build (pbs)
- GitHub Check: build (slurm)
🔇 Additional comments (4)
dpdispatcher/contexts/ssh_context.py (1)
176-206: LGTM! Good cleanup of unused exception variables.Removing the unused exception variable bindings in both SSH key loading paths is a good practice that improves code clarity without affecting functionality.
dpdispatcher/submission.py (3)
167-179: LGTM! Error messages properly consolidated.The error messages are now more readable using single f-strings instead of split strings.
219-223: LGTM! Log message formatting improved.Removing the redundant "info:" prefix makes the log output cleaner and more consistent.
836-877: LGTM! Log message formatting consistently improved.The formatting changes across the job state handling methods improve consistency by:
- Removing redundant colons after "job"
- Removing "debug:" prefixes
- Using clearer verb forms ("submitted" instead of "submit")
These changes enhance readability without affecting functionality.
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.
Pull request overview
This PR refactors log messages across the codebase to improve clarity and consistency by removing redundant log level prefixes ("debug:", "info:") from log messages, cleaning up unused exception variables, and improving message formatting. The changes align with best practices where log levels are indicated by the logging method itself rather than embedded in the message text.
Key changes:
- Removed redundant "debug:" and "info:" prefixes from dlog.debug() and dlog.info() calls
- Cleaned up unused exception variables in SSH context exception handlers
- Simplified error message formatting by consolidating multi-line strings
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| dpdispatcher/utils/dpcloudserver/client.py | Removed "debug:" prefix from three debug log messages in OSS bucket operations |
| dpdispatcher/submission.py | Removed "info:" and "debug:" prefixes from log messages, consolidated error messages, and improved job status message consistency |
| dpdispatcher/contexts/ssh_context.py | Removed unused exception variables from paramiko.SSHException handlers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| key_path, self.passphrase | ||
| ) | ||
| except paramiko.SSHException as e: | ||
| except paramiko.SSHException: |
Copilot
AI
Dec 17, 2025
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.
'except' clause does nothing but pass and there is no explanatory comment.
| try: | ||
| key = pkey_class.from_private_key_file(filename, self.passphrase) | ||
| except paramiko.SSHException as e: | ||
| except paramiko.SSHException: |
Copilot
AI
Dec 17, 2025
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.
'except' clause does nothing but pass and there is no explanatory comment.
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
🧹 Nitpick comments (2)
dpdispatcher/submission.py (2)
839-840: Consider adding a label for job_id for better clarity.The log message includes the job_id directly after the hash without a label, which could be less clear. Consider adding "job_id" label for consistency with other messages in this method.
Apply this diff for improved clarity:
- f"job {self.job_hash} {self.job_id} terminated; " + f"job {self.job_hash} job_id {self.job_id} terminated; "
849-850: Consider adding a label for job_id for better clarity.Similar to line 839, adding a "job_id" label would improve readability and consistency.
Apply this diff:
- f"job {self.job_hash} {self.job_id} failed {self.fail_count} times." + f"job {self.job_hash} job_id {self.job_id} failed {self.fail_count} times."
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dpdispatcher/submission.py(6 hunks)dpdispatcher/utils/dpcloudserver/client.py(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- dpdispatcher/utils/dpcloudserver/client.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Always add type hints in all Python code
Ensure code remains compatible with Python 3.7+ (avoid syntax/features newer than 3.7)
Use Ruff (via pre-commit) for linting and formatting
Files:
dpdispatcher/submission.py
🧬 Code graph analysis (1)
dpdispatcher/submission.py (1)
dpdispatcher/utils/job_status.py (1)
JobStatus(4-11)
🪛 Ruff (0.14.8)
dpdispatcher/submission.py
862-862: Use explicit conversion flag
Replace with conversion flag
(RUF010)
⏰ 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). (3)
- GitHub Check: test (3.11, windows-latest)
- GitHub Check: build (slurm)
- GitHub Check: build (pbs)
🔇 Additional comments (4)
dpdispatcher/submission.py (4)
170-170: LGTM: Error message consolidation improves readability.The error messages are now more concise and easier to read. The consolidation into single f-strings is a good improvement.
Also applies to: 177-177
220-222: LGTM: Log prefix removal aligns with PR objectives.Removing the redundant "info:" prefix is appropriate since the logging framework already captures the log level.
343-343: LGTM: Debug message cleanup is consistent.The removal of "debug:" prefixes and streamlined formatting improves readability while maintaining all necessary information.
Also applies to: 819-819
869-869: LGTM: Unsubmitted and submitted log messages are clear.The log messages are well-formatted and the past review feedback about using "was submitted" has been properly addressed.
Also applies to: 874-874
| f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}" | ||
| ) |
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 | 🟠 Major
Standardize job_id formatting and apply Ruff suggestion.
Line 862 uses job_id:{id} format while lines 857 and 874 use job_id is {id}. For consistency and readability, standardize to "job_id is" format. Additionally, Ruff correctly suggests using the explicit conversion flag !r instead of repr().
Apply this diff to standardize the format and fix the f-string:
- f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}"
+ f"job {self.job_hash} job_id is {self.job_id} after re-submitting; the state now is {self.job_state!r}"📝 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.
| f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}" | |
| ) | |
| f"job {self.job_hash} job_id is {self.job_id} after re-submitting; the state now is {self.job_state!r}" | |
| ) |
🧰 Tools
🪛 Ruff (0.14.8)
862-862: Use explicit conversion flag
Replace with conversion flag
(RUF010)
🤖 Prompt for AI Agents
In dpdispatcher/submission.py around lines 862-863, standardize the f-string to
use "job_id is" and apply Ruff's suggestion to use the !r conversion flag:
replace the current f-string that uses "job_id:{self.job_id}" and
repr(self.job_state) with one that uses "job_id is {self.job_id!r}" and
"{self.job_state!r}" so the message format matches surrounding lines and uses
explicit representation conversion.
Removed redundant 'debug:' and 'info:' prefixes from log messages and improved formatting for better readability.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.