Skip to content

Commit

Permalink
Add provision in odh-sync workflow to adjust Pipfile.cpu and Pipfile.…
Browse files Browse the repository at this point in the history
…gpu with codeflare-sdk release version
  • Loading branch information
abhijeet-dhumal committed Aug 22, 2024
1 parent a146547 commit ee307a9
Showing 1 changed file with 47 additions and 18 deletions.
65 changes: 47 additions & 18 deletions .github/workflows/odh-notebooks-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:

jobs:
build:
runs-on: ubuntu-20.04-4core
runs-on: ubuntu-22.04-8core
steps:
- name: Clone repository and Sync
run: |
Expand All @@ -53,6 +53,23 @@ jobs:
- name: Update Pipfiles in accordance with Codeflare-SDK latest release
run: |
package_name=codeflare-sdk
available_python_versions=("3.9") # add space separated python versions according to 'python-versions' specified in 'Setup Python Environment' step
install_package_using_pipenv(){
if ! pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}"; then
echo "Failed to install ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
exit 1
fi
# Lock dependencies, ensuring pre-release are included and clear previous state
if ! pipenv lock --pre --clear ; then
echo "Failed to lock dependencies"
exit 1
fi
# remove virtual env and clear cache
if ! pipenv --rm --clear ; then
echo "Failed to remove virtual environment"
exit 1
fi
}
# Get the list of available versions for the package
if ! versions=$(pipenv run pip-versions list $package_name);then
echo "Failed to retrieve versions for $package_name"
Expand All @@ -74,7 +91,7 @@ jobs:
#Check if current_dir is not in exclude_directories list
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
#Check if Pipfile exists in current_dir
if [ -f "$current_dir/Pipfile" ];then
if ls "$current_dir"/Pipfile* 1> /dev/null 2>&1;then
directories+=("$current_dir")
fi
fi
Expand All @@ -95,24 +112,36 @@ jobs:
cd "$dir"
minimum_supported_python_version_major=$(echo "${MINIMUM_SUPPORTED_PYTHON_VERSION}" | awk -F '.' '{print $1}') #integer of MINIMUM_SUPPORTED_PYTHON_VERSION env variable
minimum_supported_python_version_minor=$(echo "${MINIMUM_SUPPORTED_PYTHON_VERSION}" | awk -F '.' '{print $2}') #decimal of MINIMUM_SUPPORTED_PYTHON_VERSION env variable
pipfile_python_version=$(grep -E '^python_version' ./Pipfile | cut -d '"' -f 2) # extracted from pipfile
if ! [ -f "Pipfile" ]; then
if [ -f "Pipfile.cpu" ]; then
pipfile_python_version=$(grep -E '^python_version' ./Pipfile.cpu | cut -d '"' -f 2) # extracted from pipfile.cpu
fi
else
pipfile_python_version=$(grep -E '^python_version' ./Pipfile | cut -d '"' -f 2) # extracted from pipfile
fi
pipfile_python_version_major=$(echo "$pipfile_python_version" | awk -F '.' '{print $1}')
pipfile_python_version_minor=$(echo "$pipfile_python_version" | awk -F '.' '{print $2}')
if [[ "pipfile_python_version_major" -ge "$minimum_supported_python_version_major" && "pipfile_python_version_minor" -ge "$minimum_supported_python_version_minor" ]]; then
#install specified package
if ! pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}"; then
echo "Failed to install ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
exit 1
fi
# Lock dependencies, ensuring pre-release are included and clear previous state
if ! pipenv lock --pre --clear ; then
echo "Failed to lock dependencies"
exit 1
fi
# remove virtual env and clear cache
if ! pipenv --rm --clear ; then
echo "Failed to remove virtual environment"
exit 1
if [[ " ${available_python_versions[@]} " =~ " ${pipfile_python_version} " && "$pipfile_python_version_major" -ge "$minimum_supported_python_version_major" && "$pipfile_python_version_minor" -ge "$minimum_supported_python_version_minor" ]]; then
if ! [ -f "Pipfile" ]; then
if [ -f "Pipfile.cpu" ]; then
mv Pipfile.cpu Pipfile
mv Pipfile.lock.cpu Pipfile.lock
#install specified package
install_package_using_pipenv
mv Pipfile.lock Pipfile.lock.cpu
mv Pipfile Pipfile.cpu
fi
if [ -f "Pipfile.gpu" ]; then
mv Pipfile.gpu Pipfile
mv Pipfile.lock.gpu Pipfile.lock
#install specified package
install_package_using_pipenv
mv Pipfile.lock Pipfile.lock.gpu
mv Pipfile Pipfile.gpu
fi
else
#install specified package
install_package_using_pipenv
fi
else
echo "Skipped installation of ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
Expand Down

0 comments on commit ee307a9

Please sign in to comment.