Skip to content

Conversation

@misiugodfrey
Copy link
Contributor

@misiugodfrey misiugodfrey commented Oct 23, 2025

The pbench config script was swallowing errors such that it was not clear when it failed (and the presto start scripts would continue even if it had, using/creating invalid config files). With this patch we cast mem values to int (the original failure was from floats being passed in and failing parsing), we check the pbench output for errors, and will have the script return an error value if the config failed (thereby halting the start* scripts if they call it and fail).

Summary by CodeRabbit

  • New Features

    • Added GPU-specific configuration support with automatic worker CPU allocation adjustment based on variant type.
  • Bug Fixes

    • Enhanced configuration generation with improved error detection and user-friendly error messaging.
    • Refined RAM calculation for more accurate configuration values.
  • Chores

    • Improved logging output with color-coded messages for better visibility.

@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The shell script now includes colorized logging helpers, integer-cast RAM calculation, VARIANT_TYPE validation with GPU-specific vCPU configuration, and post-generation error detection with status messaging.

Changes

Cohort / File(s) Summary
Logging and Error Handling
presto/scripts/generate_presto_config.sh
Added color constants (RED, GREEN, YELLOW, NC) and logging helpers (echo_error, echo_success) for colorized terminal output
Configuration Calculations
presto/scripts/generate_presto_config.sh
Modified RAM_GB calculation to use integer casting; introduced VARIANT_TYPE validation with conditional VCPU_PER_WORKER logic (2 for GPU variant, NPROC otherwise)
Post-Generation Validation
presto/scripts/generate_presto_config.sh
Added error pattern detection after pbench genconfig execution; exits with descriptive error on failure, prints success message on completion

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The changes are straightforward enhancements: addition of helper functions and color constants, a single calculation improvement, and conditional logic for variant handling. While multiple types of changes are present, they follow consistent patterns and add minimal complexity to the existing flow.

Poem

🐰 With rainbow logs and error so clear,
The config script brings joy and good cheer!
GPU or CPU, no more confusion,
Just colorful truth—no more illusion! 🌈✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Added casting, and error checking for pbench config script" is fully related to the main changes in the changeset. The raw summary confirms that the patch introduces two key modifications: (1) an integer-cast variant using int(...) for the RAM_GB calculation to handle float parsing issues, and (2) guarded post-generation messaging that checks pbench output for errors and exits with a descriptive error on failure. The title is clear, specific, and concise enough that a teammate scanning the repository history would understand the primary technical improvements being made to the pbench config script without requiring additional context.

Comment @coderabbitai help to get the list of available commands and usage tips.

@misiugodfrey
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a 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)
presto/scripts/generate_presto_config.sh (2)

19-22: Remove unused YELLOW color constant.

The static analysis tool correctly identifies that YELLOW is never used in the script. Remove it to avoid confusion and maintain clean code.

 RED='\033[0;31m'
 GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
 NC='\033[0m' # No Color

83-86: Remove unreachable exit 1 statement.

The exit 1 on line 85 is unreachable because echo_error (defined on lines 24–27) already exits the script with status 1. Remove the redundant statement:

 if ../../pbench/pbench genconfig -p params.json -t template generated 2>&1 | grep '\{\"level":"error"'; then
     echo_error "ERROR in pbench genconfig.  Configs were not generated successfully"
-    exit 1
 fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56d246e and b2a2005.

📒 Files selected for processing (1)
  • presto/scripts/generate_presto_config.sh (3 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
presto/scripts/generate_presto_config.sh

[warning] 21-21: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)

🔇 Additional comments (5)
presto/scripts/generate_presto_config.sh (5)

24-31: Well-designed logging helpers.

The echo_error and echo_success functions provide consistent, colorized output and proper exit handling. Clean implementation.


41-41: Integer casting for memory value is correct.

The int() cast in the awk expression properly addresses the original issue of floats breaking config parsing. The calculation correctly converts bytes to GB.


47-50: Solid validation of VARIANT_TYPE.

The regex check ensures only valid variant types are accepted, preventing misconfigurations. Clear error messaging.


51-55: GPU-specific vCPU configuration is appropriate.

The logic correctly assigns fewer vCPUs for GPU variants while preserving full CPU count for CPU/Java variants.


83-86: Verify that pbench error detection covers all failure modes.

The current error detection pattern \{\"level":"error" assumes pbench always outputs JSON-formatted errors. If pbench can fail in other ways (exit with error code but no error JSON output), those failures would be missed.

Please confirm: does pbench consistently format errors as JSON with {"level":"error", or are there other failure modes that should be caught?

Copy link
Contributor

@simoneves simoneves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but maybe the fancy logging is a little PR-creep-y?

function echo_success {
echo -e "${GREEN}$1${NC}"
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, but maybe this stuff could move to the shared-parser PR or some other all-scripts clean-up, to avoid proliferating custom code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, CodeRabbit is not wrong...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually already in a PR I have here: #60
Folks wanted me to wait until things are a bit less in flux before landing it though, as it touches a lot of our scripts. My intention is to land this with the helper functions, and then I can replace them easily when PR 60 lands by remove the functions and sourcing the shared helper script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention is to land this with the helper functions, and then I can replace them easily when PR 60 lands by remove the functions and sourcing the shared helper script.

Fair enough!

@misiugodfrey misiugodfrey merged commit b3848d5 into main Oct 23, 2025
1 check passed
@misiugodfrey misiugodfrey deleted the misiug/PatchPbenchScript branch October 23, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants