2929
3030jobs :
3131 build :
32- runs-on : ubuntu-20 .04-4core
32+ runs-on : ubuntu-22 .04-8core
3333 steps :
3434 - name : Clone repository and Sync
3535 run : |
5353 - name : Update Pipfiles in accordance with Codeflare-SDK latest release
5454 run : |
5555 package_name=codeflare-sdk
56+ available_python_versions=("3.9") # add space separated python versions according to 'python-versions' specified in 'Setup Python Environment' step
57+ install_package_using_pipenv(){
58+ if ! pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}"; then
59+ echo "Failed to install ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
60+ exit 1
61+ fi
62+ # Lock dependencies, ensuring pre-release are included and clear previous state
63+ if ! pipenv lock --pre --clear ; then
64+ echo "Failed to lock dependencies"
65+ exit 1
66+ fi
67+ # remove virtual env and clear cache
68+ if ! pipenv --rm --clear ; then
69+ echo "Failed to remove virtual environment"
70+ exit 1
71+ fi
72+ }
5673 # Get the list of available versions for the package
5774 if ! versions=$(pipenv run pip-versions list $package_name);then
5875 echo "Failed to retrieve versions for $package_name"
7491 #Check if current_dir is not in exclude_directories list
7592 if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
7693 #Check if Pipfile exists in current_dir
77- if [ -f "$current_dir/Pipfile" ] ;then
94+ if ls "$current_dir" /Pipfile* 1> /dev/null 2>&1 ;then
7895 directories+=("$current_dir")
7996 fi
8097 fi
@@ -95,24 +112,36 @@ jobs:
95112 cd "$dir"
96113 minimum_supported_python_version_major=$(echo "${MINIMUM_SUPPORTED_PYTHON_VERSION}" | awk -F '.' '{print $1}') #integer of MINIMUM_SUPPORTED_PYTHON_VERSION env variable
97114 minimum_supported_python_version_minor=$(echo "${MINIMUM_SUPPORTED_PYTHON_VERSION}" | awk -F '.' '{print $2}') #decimal of MINIMUM_SUPPORTED_PYTHON_VERSION env variable
98- pipfile_python_version=$(grep -E '^python_version' ./Pipfile | cut -d '"' -f 2) # extracted from pipfile
115+ if ! [ -f "Pipfile" ]; then
116+ if [ -f "Pipfile.cpu" ]; then
117+ pipfile_python_version=$(grep -E '^python_version' ./Pipfile.cpu | cut -d '"' -f 2) # extracted from pipfile.cpu
118+ fi
119+ else
120+ pipfile_python_version=$(grep -E '^python_version' ./Pipfile | cut -d '"' -f 2) # extracted from pipfile
121+ fi
99122 pipfile_python_version_major=$(echo "$pipfile_python_version" | awk -F '.' '{print $1}')
100123 pipfile_python_version_minor=$(echo "$pipfile_python_version" | awk -F '.' '{print $2}')
101- if [[ "pipfile_python_version_major" -ge "$minimum_supported_python_version_major" && "pipfile_python_version_minor" -ge "$minimum_supported_python_version_minor" ]]; then
102- #install specified package
103- if ! pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}"; then
104- echo "Failed to install ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
105- exit 1
106- fi
107- # Lock dependencies, ensuring pre-release are included and clear previous state
108- if ! pipenv lock --pre --clear ; then
109- echo "Failed to lock dependencies"
110- exit 1
111- fi
112- # remove virtual env and clear cache
113- if ! pipenv --rm --clear ; then
114- echo "Failed to remove virtual environment"
115- exit 1
124+ 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
125+ if ! [ -f "Pipfile" ]; then
126+ if [ -f "Pipfile.cpu" ]; then
127+ mv Pipfile.cpu Pipfile
128+ mv Pipfile.lock.cpu Pipfile.lock
129+ #install specified package
130+ install_package_using_pipenv
131+ mv Pipfile.lock Pipfile.lock.cpu
132+ mv Pipfile Pipfile.cpu
133+ fi
134+ if [ -f "Pipfile.gpu" ]; then
135+ mv Pipfile.gpu Pipfile
136+ mv Pipfile.lock.gpu Pipfile.lock
137+ #install specified package
138+ install_package_using_pipenv
139+ mv Pipfile.lock Pipfile.lock.gpu
140+ mv Pipfile Pipfile.gpu
141+ fi
142+ else
143+ #install specified package
144+ install_package_using_pipenv
116145 fi
117146 else
118147 echo "Skipped installation of ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
0 commit comments