Skip to content

[RHOAIENG-17006] Change the scripts so that it runs with uv #1240

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

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/uv-renewal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# This GitHub action is meant to update the pipfile.locks
name: uv.locks Renewal Action

on: # yamllint disable-line rule:truthy
# Triggers the workflow every Wednesday at 1am UTC
schedule:
- cron: "0 1 * * 3"
workflow_dispatch: # for manual trigger workflow from GH Web UI
inputs:
branch:
description: 'Specify branch'
required: false
default: 'main'
python_version:
description: 'Select Python version to update uv.lock'
required: false
default: '3.11'
type: choice
options:
- '3.12'
- '3.11'
update_optional_dirs:
description: 'Include optional directories in update'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
env:
BRANCH: ${{ github.event.inputs.branch || 'main' }}
PYTHON_VERSION: ${{ github.event.inputs.python_version || '3.11' }}
INCLUDE_OPT_DIRS: ${{ github.event.inputs.update_optional_dirs || 'false' }}
steps:
# Checkout the specified branch from the specified organization
- name: Checkout code from the specified branch
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}

# Configure Git
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"

# Setup Python environment with the specified version (or default to '3.11')
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

# Install uv
- name: Install uv
run: pip install uv

# Run makefile recipe to refresh uv.lock and push changes back to the branch
- name: Run make refresh-pipfilelock-files and push the changes back to the branch
run: |
uv lock --python ${{ env.PYTHON_VERSION }}
git add uv.lock
git commit -m "Update uv.lock files by uvlock-renewal.yaml action"
git push origin ${{ env.BRANCH }}
26 changes: 21 additions & 5 deletions scripts/sync-requirements-txt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@ set -Eeuxo pipefail
# Namely, Konflux (https://konflux-ci.dev/), and Cachi2 (https://github.com/containerbuildsystem/cachi2).

# The following will create an extra requirement.txt file for every Pipfile.lock we have.
micropipenv --version || pip install micropipenv
find . -name Pipfile.lock -execdir bash -c '
echo "# Generated by /scripts/sync-requirements-txt.sh from Pipfile.lock" > requirements.txt &&
echo >> requirements.txt &&
micropipenv requirements >> requirements.txt' \;
uv --version || pip install uv
cd jupyter
find . -name "requirements.txt" -type f > files.txt
cd ..
while read -r file; do

echo "Processing $file"
path="${file#./*}"
image_name="${path%/*/*}"
python_version="${path%/*}"
python_version="${python_version##*-}"

if [[ "$path" == *"rocm/"* ]]; then
image_name="${image_name#*/}-rocm"
fi

Comment on lines +15 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect image name for nested “rocm/…” paths

The current string-mangling turns pytorch/rocm/... into rocm-rocm.
A safer approach extracts the first directory (framework) and appends -rocm only once.

-  image_name="${path%/*/*}"
-  ...
-  if [[ "$path" == *"rocm/"* ]]; then
-    image_name="${image_name#*/}-rocm"
-  fi
+  # derive image name (first path component) and decorate for ROCm if needed
+  image_name="${path%%/*}"           # e.g. pytorch, tensorflow, rocm
+  if [[ "$image_name" == "rocm" ]]; then
+    # path like rocm/tensorflow/..., so pick second component and tag with -rocm
+    image_name="$(echo "$path" | cut -d'/' -f2)-rocm"
+  fi

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In scripts/sync-requirements-txt.sh around lines 15 to 23, the current code
incorrectly constructs the image_name for nested "rocm/..." paths, resulting in
names like "rocm-rocm". To fix this, extract only the first directory from the
path as the base image_name and append "-rocm" once if the path contains
"rocm/". This ensures the image_name correctly reflects the top-level framework
with a single "-rocm" suffix.

uv pip compile --format requirements.txt --python ${python_version} -o jupyter/${path} --generate-hashes --group jupyter-${image_name}-image --python-platform linux --no-annotate -q

done < jupyter/files.txt

rm jupyter/files.txt
Loading