|
| 1 | +name: Update Ray Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + new_ray_version: |
| 7 | + description: 'New Ray version (e.g., 2.48.0) - Leave empty to skip' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + default: '' |
| 11 | + new_cuda_py311_sha: |
| 12 | + description: 'New CUDA Python 3.11 runtime image SHA (e.g., abc123...) - Leave empty to skip' |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: '' |
| 16 | + new_cuda_py312_sha: |
| 17 | + description: 'New CUDA Python 3.12 runtime image SHA (e.g., def456...) - Leave empty to skip' |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: '' |
| 21 | + new_cuda_version_py311: |
| 22 | + description: 'New CUDA version for Python 3.11 (e.g., cu121) - Leave empty to skip' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + default: '' |
| 26 | + new_cuda_version_py312: |
| 27 | + description: 'New CUDA version for Python 3.12 (e.g., cu128) - Leave empty to skip' |
| 28 | + required: false |
| 29 | + type: string |
| 30 | + default: '' |
| 31 | + |
| 32 | +env: |
| 33 | + PR_BRANCH_NAME: ray-version-update-${{ github.run_id }} |
| 34 | + |
| 35 | +jobs: |
| 36 | + update-ray-version: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + permissions: |
| 39 | + contents: write |
| 40 | + pull-requests: write |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Set up Python |
| 49 | + uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: '3.11' |
| 52 | + |
| 53 | + - name: Configure git and create branch |
| 54 | + run: | |
| 55 | + git config --local user.email "[email protected]" |
| 56 | + git config --local user.name "GitHub Action" |
| 57 | + git checkout main |
| 58 | + git pull origin main |
| 59 | + git checkout -b ${{ env.PR_BRANCH_NAME }} |
| 60 | +
|
| 61 | + - name: Update constants.py |
| 62 | + run: | |
| 63 | + echo "Updating constants.py with provided parameters..." |
| 64 | +
|
| 65 | + # Update Ray version if provided |
| 66 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 67 | + echo "Updating Ray version to ${{ github.event.inputs.new_ray_version }}" |
| 68 | + sed -i "s/RAY_VERSION = \"[^\"]*\"/RAY_VERSION = \"${{ github.event.inputs.new_ray_version }}\"/" src/codeflare_sdk/common/utils/constants.py |
| 69 | +
|
| 70 | + # Update comments with new Ray version and CUDA versions if both are provided |
| 71 | + if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 72 | + sed -i "s/\* For python 3.11:ray:[^\"]*/\* For python 3.11:ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/" src/codeflare_sdk/common/utils/constants.py |
| 73 | + fi |
| 74 | + if [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then |
| 75 | + sed -i "s/\* For python 3.12:ray:[^\"]*/\* For python 3.12:ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/" src/codeflare_sdk/common/utils/constants.py |
| 76 | + fi |
| 77 | + fi |
| 78 | +
|
| 79 | + # Update runtime image SHAs if provided |
| 80 | + if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then |
| 81 | + echo "Updating Python 3.11 runtime image SHA" |
| 82 | + sed -i "s/CUDA_PY311_RUNTIME_IMAGE = \"quay\.io\/modh\/ray@sha256:[^\"]*\"/CUDA_PY311_RUNTIME_IMAGE = \"quay.io\/modh\/ray@sha256:${{ github.event.inputs.new_cuda_py311_sha }}\"/" src/codeflare_sdk/common/utils/constants.py |
| 83 | + fi |
| 84 | +
|
| 85 | + if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then |
| 86 | + echo "Updating Python 3.12 runtime image SHA" |
| 87 | + sed -i "s/CUDA_PY312_RUNTIME_IMAGE = \"quay\.io\/modh\/ray@sha256:[^\"]*\"/CUDA_PY312_RUNTIME_IMAGE = \"quay.io\/modh\/ray@sha256:${{ github.event.inputs.new_cuda_py312_sha }}\"/" src/codeflare_sdk/common/utils/constants.py |
| 88 | + fi |
| 89 | +
|
| 90 | + echo "Constants.py update completed" |
| 91 | +
|
| 92 | + - name: Update pyproject.toml |
| 93 | + run: | |
| 94 | + # Update Ray dependency version in pyproject.toml if Ray version is provided |
| 95 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 96 | + echo "Updating pyproject.toml with Ray version ${{ github.event.inputs.new_ray_version }}" |
| 97 | + sed -i "s/ray = {version = \"[^\"]*\", extras = \[\"data\", \"default\"\]}/ray = {version = \"${{ github.event.inputs.new_ray_version }}\", extras = [\"data\", \"default\"]}/" pyproject.toml |
| 98 | + echo "pyproject.toml updated successfully" |
| 99 | + else |
| 100 | + echo "Skipping pyproject.toml update - no Ray version provided" |
| 101 | + fi |
| 102 | +
|
| 103 | + - name: Update documentation files |
| 104 | + run: | |
| 105 | + # Update documentation files with new Ray version and image tags if provided |
| 106 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 107 | + echo "Updating documentation files with Ray ${{ github.event.inputs.new_ray_version }} and CUDA ${{ github.event.inputs.new_cuda_version_py311 }}" |
| 108 | + find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \; |
| 109 | + find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-rocm[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-rocm62/g" {} \; |
| 110 | + fi |
| 111 | +
|
| 112 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then |
| 113 | + echo "Updating documentation files with Ray ${{ github.event.inputs.new_ray_version }} and CUDA ${{ github.event.inputs.new_cuda_version_py312 }}" |
| 114 | + find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py312-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/g" {} \; |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: Update notebook files |
| 118 | + run: | |
| 119 | + # Update notebook files with new Ray version and image tags if provided |
| 120 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 121 | + echo "Updating notebook files with Ray ${{ github.event.inputs.new_ray_version }} and CUDA ${{ github.event.inputs.new_cuda_version_py311 }}" |
| 122 | + find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \; |
| 123 | + fi |
| 124 | +
|
| 125 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then |
| 126 | + echo "Updating notebook files with Ray ${{ github.event.inputs.new_ray_version }} and CUDA ${{ github.event.inputs.new_cuda_version_py312 }}" |
| 127 | + find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py312-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/g" {} \; |
| 128 | + fi |
| 129 | +
|
| 130 | + - name: Update YAML test files |
| 131 | + run: | |
| 132 | + # Update YAML files with new Ray version if provided |
| 133 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 134 | + echo "Updating YAML test files with Ray version ${{ github.event.inputs.new_ray_version }}" |
| 135 | + find tests/ -name "*.yaml" -exec sed -i "s/rayVersion: [0-9]\+\.[0-9]\+\.[0-9]\+/rayVersion: ${{ github.event.inputs.new_ray_version }}/g" {} \; |
| 136 | + fi |
| 137 | +
|
| 138 | + # Update image tags in YAML files if Ray version and CUDA versions are provided |
| 139 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 140 | + find tests/ -name "*.yaml" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \; |
| 141 | + fi |
| 142 | +
|
| 143 | + - name: Update output YAML files |
| 144 | + run: | |
| 145 | + # Update output YAML files in demo-notebooks if Ray version and CUDA version are provided |
| 146 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 147 | + echo "Updating output YAML files with Ray ${{ github.event.inputs.new_ray_version }} and CUDA ${{ github.event.inputs.new_cuda_version_py311 }}" |
| 148 | + find demo-notebooks/ -name "*.yaml" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \; |
| 149 | + fi |
| 150 | +
|
| 151 | + - name: Validate updates |
| 152 | + run: | |
| 153 | + echo "Validating updates..." |
| 154 | +
|
| 155 | + # Check if constants.py was updated correctly (only if Ray version was provided) |
| 156 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 157 | + if grep -q "RAY_VERSION = \"${{ github.event.inputs.new_ray_version }}\"" src/codeflare_sdk/common/utils/constants.py; then |
| 158 | + echo "✓ Ray version updated in constants.py" |
| 159 | + else |
| 160 | + echo "✗ Ray version not found in constants.py" |
| 161 | + exit 1 |
| 162 | + fi |
| 163 | +
|
| 164 | + # Check if pyproject.toml was updated correctly |
| 165 | + if grep -q "ray = {version = \"${{ github.event.inputs.new_ray_version }}\"" pyproject.toml; then |
| 166 | + echo "✓ Ray version updated in pyproject.toml" |
| 167 | + else |
| 168 | + echo "✗ Ray version not found in pyproject.toml" |
| 169 | + exit 1 |
| 170 | + fi |
| 171 | + fi |
| 172 | +
|
| 173 | + # Check if runtime images were updated (only if SHAs were provided) |
| 174 | + if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then |
| 175 | + if grep -q "quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py311_sha }}" src/codeflare_sdk/common/utils/constants.py; then |
| 176 | + echo "✓ Python 3.11 runtime image updated" |
| 177 | + else |
| 178 | + echo "✗ Python 3.11 runtime image not found" |
| 179 | + exit 1 |
| 180 | + fi |
| 181 | + fi |
| 182 | +
|
| 183 | + if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then |
| 184 | + if grep -q "quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py312_sha }}" src/codeflare_sdk/common/utils/constants.py; then |
| 185 | + echo "✓ Python 3.12 runtime image updated" |
| 186 | + else |
| 187 | + echo "✗ Python 3.12 runtime image not found" |
| 188 | + exit 1 |
| 189 | + fi |
| 190 | + fi |
| 191 | +
|
| 192 | + echo "All validations passed!" |
| 193 | +
|
| 194 | + - name: Check for changes |
| 195 | + id: check-changes |
| 196 | + run: | |
| 197 | + if git diff --quiet; then |
| 198 | + echo "No changes detected" |
| 199 | + echo "has-changes=false" >> $GITHUB_OUTPUT |
| 200 | + else |
| 201 | + echo "Changes detected" |
| 202 | + echo "has-changes=true" >> $GITHUB_OUTPUT |
| 203 | + echo "Summary of changes:" |
| 204 | + git diff --stat |
| 205 | + fi |
| 206 | +
|
| 207 | + - name: Commit changes |
| 208 | + if: steps.check-changes.outputs.has-changes == 'true' |
| 209 | + run: | |
| 210 | + git add . |
| 211 | +
|
| 212 | + # Build commit message based on what was updated |
| 213 | + COMMIT_MSG="Update Ray configuration" |
| 214 | +
|
| 215 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 216 | + COMMIT_MSG="$COMMIT_MSG |
| 217 | +
|
| 218 | + - Updated Ray version to ${{ github.event.inputs.new_ray_version }} in constants.py and pyproject.toml" |
| 219 | + fi |
| 220 | +
|
| 221 | + if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then |
| 222 | + COMMIT_MSG="$COMMIT_MSG |
| 223 | + - Updated Python 3.11 CUDA runtime image SHA" |
| 224 | + fi |
| 225 | +
|
| 226 | + if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then |
| 227 | + COMMIT_MSG="$COMMIT_MSG |
| 228 | + - Updated Python 3.12 CUDA runtime image SHA" |
| 229 | + fi |
| 230 | +
|
| 231 | + if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ] || [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then |
| 232 | + COMMIT_MSG="$COMMIT_MSG |
| 233 | + - Updated documentation and notebook files with new CUDA versions" |
| 234 | + fi |
| 235 | +
|
| 236 | + COMMIT_MSG="$COMMIT_MSG |
| 237 | +
|
| 238 | + Parameters provided: |
| 239 | + - Ray version: ${{ github.event.inputs.new_ray_version }} |
| 240 | + - Python 3.11 CUDA version: ${{ github.event.inputs.new_cuda_version_py311 }} |
| 241 | + - Python 3.12 CUDA version: ${{ github.event.inputs.new_cuda_version_py312 }} |
| 242 | + - Python 3.11 runtime SHA: ${{ github.event.inputs.new_cuda_py311_sha }} |
| 243 | + - Python 3.12 runtime SHA: ${{ github.event.inputs.new_cuda_py312_sha }}" |
| 244 | +
|
| 245 | + git commit -m "$COMMIT_MSG" |
| 246 | +
|
| 247 | + - name: Push changes |
| 248 | + if: steps.check-changes.outputs.has-changes == 'true' |
| 249 | + run: | |
| 250 | + git push origin ${{ env.PR_BRANCH_NAME }} |
| 251 | +
|
| 252 | + - name: Create Pull Request |
| 253 | + if: steps.check-changes.outputs.has-changes == 'true' |
| 254 | + run: | |
| 255 | + # Build PR title and body based on what was updated |
| 256 | + PR_TITLE="Update Ray configuration" |
| 257 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 258 | + PR_TITLE="Update Ray version to ${{ github.event.inputs.new_ray_version }}" |
| 259 | + fi |
| 260 | +
|
| 261 | + PR_BODY="## Ray Configuration Update |
| 262 | +
|
| 263 | + This PR automatically updates Ray configuration across the repository. |
| 264 | +
|
| 265 | + ### Changes Made:" |
| 266 | +
|
| 267 | + if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then |
| 268 | + PR_BODY="$PR_BODY |
| 269 | + - **Ray Version**: Updated to \`${{ github.event.inputs.new_ray_version }}\`" |
| 270 | + fi |
| 271 | +
|
| 272 | + if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then |
| 273 | + PR_BODY="$PR_BODY |
| 274 | + - **Python 3.11 CUDA Version**: \`${{ github.event.inputs.new_cuda_version_py311 }}\`" |
| 275 | + fi |
| 276 | +
|
| 277 | + if [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then |
| 278 | + PR_BODY="$PR_BODY |
| 279 | + - **Python 3.12 CUDA Version**: \`${{ github.event.inputs.new_cuda_version_py312 }}\`" |
| 280 | + fi |
| 281 | +
|
| 282 | + if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then |
| 283 | + PR_BODY="$PR_BODY |
| 284 | + - **Python 3.11 Runtime SHA**: \`${{ github.event.inputs.new_cuda_py311_sha }}\`" |
| 285 | + fi |
| 286 | +
|
| 287 | + if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then |
| 288 | + PR_BODY="$PR_BODY |
| 289 | + - **Python 3.12 Runtime SHA**: \`${{ github.event.inputs.new_cuda_py312_sha }}\`" |
| 290 | + fi |
| 291 | +
|
| 292 | + PR_BODY="$PR_BODY |
| 293 | +
|
| 294 | + ### Files Updated: |
| 295 | + - \`src/codeflare_sdk/common/utils/constants.py\` - Ray version, comments, and runtime image SHAs |
| 296 | + - \`pyproject.toml\` - Ray dependency version (if Ray version provided) |
| 297 | + - Documentation files (\`.rst\`) - Updated Ray image tags (if versions provided) |
| 298 | + - Notebook files (\`.ipynb\`) - Updated Ray image tags (if versions provided) |
| 299 | + - YAML test files - Updated Ray version and image tags (if versions provided) |
| 300 | +
|
| 301 | + ### Testing: |
| 302 | + Please run the test suite to ensure all changes work correctly: |
| 303 | + \`\`\`bash |
| 304 | + poetry install |
| 305 | + poetry run pytest |
| 306 | + \`\`\` |
| 307 | +
|
| 308 | + ### Review Checklist: |
| 309 | + - [ ] Verify Ray version is correctly updated in all files |
| 310 | + - [ ] Check that runtime image SHAs are valid |
| 311 | + - [ ] Ensure documentation examples are updated |
| 312 | + - [ ] Run tests to verify compatibility" |
| 313 | +
|
| 314 | + # Create PR using GitHub CLI |
| 315 | + gh pr create \ |
| 316 | + --title "$PR_TITLE" \ |
| 317 | + --body "$PR_BODY" \ |
| 318 | + --base main \ |
| 319 | + --head ${{ env.PR_BRANCH_NAME }} \ |
| 320 | + --label "automated,ray-version-update" |
| 321 | + env: |
| 322 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 323 | + |
| 324 | + - name: Comment on workflow run |
| 325 | + if: steps.check-changes.outputs.has-changes == 'false' |
| 326 | + run: | |
| 327 | + echo "No changes were made. This could mean:" |
| 328 | + echo "1. The Ray version is already up to date" |
| 329 | + echo "2. The input parameters didn't match any existing patterns" |
| 330 | + echo "3. There was an issue with the update process" |
| 331 | + echo "" |
| 332 | + echo "Please verify the input parameters and try again." |
0 commit comments