-
Notifications
You must be signed in to change notification settings - Fork 30
Update bitaxe_hashrate_benchmark.py #3
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: main
Are you sure you want to change the base?
Conversation
Couple of changes: - color not working in windows terminal - suffix in filename in case of voltage/frequency argument - limited (1 successive) retries in case of overheat (previously any chip overheat reached ended the benchmark)
""" WalkthroughThe changes add Windows terminal ANSI color support, enhance result file naming to reflect custom initial voltage and frequency, and refine the benchmarking loop to allow a single retry with increased voltage upon overheating. Informative print statements clarify the benchmarking process, and output filenames now consistently include the parameter-based suffix. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (8)
✨ 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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
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
♻️ Duplicate comments (1)
bitaxe_hashrate_benchmark.py (1)
477-478
: Filename duplication block – reuse shared helperSee earlier comment on
_result_filename()
. The build logic is now duplicated twice; refactor to single source of truth to prevent silent divergence.
🧹 Nitpick comments (3)
bitaxe_hashrate_benchmark.py (3)
8-10
: Prefercolorama
overos.system("")
for Windows ANSI support
os.system("")
is an undocumented trick; it silently spawnscmd.exe
with an empty command, which side-effects the console state on some Windows builds but is a no-op everywhere else.
colorama.init()
is the de-facto cross-platform solution and makes the intent explicit.-import os -os.system("") # enables ansi escape characters in terminal - colors were not working in Windows terminal +import os +try: + import colorama + colorama.init() +except ImportError: + # Fallback for environments where colorama isn't available + if os.name == "nt": + os.system("") # rudimentary ANSI enable on Windows
318-323
: Duplicate filename logic – keepsave_results()
DRY
save_results()
replicates the samefilename
construction that is later duplicated in the final summary section (≈ line 475). Extract the logic into a small helper to avoid divergence if the pattern ever changes.def _result_filename(): ip_address = bitaxe_ip.replace('http://', '') return f"bitaxe_benchmark_results_{ip_address}{file_suffix}.json"Use it in both places.
400-416
: 8-clause boolean is hard to read – extract intent into named predicatesPylint rightfully flags the
if
spanning lines 402-412. Readability and maintainability suffer; a one-line change in the retry policy becomes a scavenger hunt.- if avg_hashrate is None and avg_temp is None and efficiency_jth is None and hashrate_ok is False and avg_vr_temp is None and error_reason == 'CHIP_TEMP_EXCEEDED' and initial_frequency <= current_frequency + frequency_increment and retry_upon_overheat < 1: + overheat_retry_allowed = ( + error_reason == "CHIP_TEMP_EXCEEDED" + and retry_upon_overheat < 1 + and initial_frequency <= current_frequency + frequency_increment + ) + + if overheat_retry_allowed:Besides clarity, this makes the section self-documenting and satisfies R0916.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bitaxe_hashrate_benchmark.py
(7 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
bitaxe_hashrate_benchmark.py
[refactor] 402-402: Too many boolean expressions in if statement (8/5)
(R0916)
Couple of changes: - color not working in windows terminal - timestamp in filename - suffix in filename in case of voltage/frequency argument - filename computation refactored (called twice) - limited (1 successive) retries in case of overheat (previously any chip overheat reached ended the benchmark)
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.
Couple of changes:
- color not working in windows terminal
- timestamp in filename
- suffix in filename in case of voltage/frequency argument
- filename computation refactored (called twice)
- limited (1 successive) retries in case of overheat (previously any chip overheat reached ended the benchmark)
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: 2
♻️ Duplicate comments (1)
bitaxe_hashrate_benchmark.py (1)
89-94
: File suffix generation addresses previous spacing concerns.The implementation now uses underscores instead of spaces, which resolves the previous review feedback about awkward filenames with leading spaces.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bitaxe_hashrate_benchmark.py
(7 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
bitaxe_hashrate_benchmark.py
19-19: Redefinition of unused time
from line 2
Remove definition: time
(F811)
🔇 Additional comments (6)
bitaxe_hashrate_benchmark.py (6)
8-16
: ANSI color support implementation looks good.The Windows terminal color support implementation with colorama fallback is well-structured and handles the ImportError gracefully.
96-100
: Good refactoring of filename generation into reusable function.The
result_filename()
function centralizes filename generation logic, improving maintainability and consistency across the codebase.
375-375
: Initialize retry counter for overheating logic.The addition of
retry_upon_overheat
variable is appropriate for implementing the single-retry mechanism described in the PR objectives.
401-413
: User feedback messages enhance usability.The addition of informative print statements provides valuable feedback to users about the benchmarking process state and decisions being made.
335-336
: Consistent use of centralized filename function.Both locations now use the
result_filename()
function, ensuring consistent filename generation throughout the script.Also applies to: 496-497
424-432
: Overheating retry implementation needs voltage limit validation.The retry logic increases voltage but doesn't validate against
max_allowed_voltage
before setting the new frequency. This could lead to inconsistent state if voltage validation fails later.Move the voltage validation to the beginning of the retry block:
if overheat_retry_allowed: - # If overheat, return to initial frequency while increasing voltage (considering max_allowed_voltage) retry_upon_overheat += 1 - if current_voltage + voltage_increment <= max_allowed_voltage: - current_frequency = initial_frequency - current_voltage += voltage_increment - print(GREEN + "Reached thermal limit for the current voltage/frequency. Switching to next voltage increment." + RESET) - else: - print(GREEN + "Reached thermal limit for the current voltage/frequency. Next voltage increment out of voltage limit. Stopping further testing." + RESET) - break # We've reached max voltage, can't increase voltage anymore + # If overheat, return to initial frequency while increasing voltage + current_frequency = initial_frequency + current_voltage += voltage_increment + print(GREEN + "Reached thermal limit for the current voltage/frequency. Switching to next voltage increment." + RESET)The voltage limit check is already handled in the
overheat_retry_allowed
condition above.Likely an incorrect or invalid review comment.
Couple of changes:
Summary by CodeRabbit
New Features
Bug Fixes
Enhancements