From b8328aead99310dcf8af46503b22fc3cfed12a98 Mon Sep 17 00:00:00 2001 From: abhijeet-dhumal Date: Tue, 20 Aug 2024 14:45:00 +0530 Subject: [PATCH] Add provision in odh-sync workflow to adjust Pipfile.cpu and Pipfile.gpu with codeflare-sdk release version --- .github/workflows/odh-notebooks-sync.yml | 65 +++++++++++++++++------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/.github/workflows/odh-notebooks-sync.yml b/.github/workflows/odh-notebooks-sync.yml index 9ce1858fe..00a9c2dee 100644 --- a/.github/workflows/odh-notebooks-sync.yml +++ b/.github/workflows/odh-notebooks-sync.yml @@ -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: | @@ -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" @@ -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 @@ -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"