Skip to content

Commit 33b4fd5

Browse files
committed
small refactor of odh-notebooks-sync.yml
Signed-off-by: Kevin <[email protected]>
1 parent 73c4e9f commit 33b4fd5

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

.github/workflows/odh-notebooks-sync.yml

+13-37
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ jobs:
5757
package_name=codeflare-sdk
5858
available_python_versions=("3.9", "3.11") # add space separated python versions according to 'python-versions' specified in 'Setup Python Environment' step
5959
install_package_using_pipenv(){
60+
# args allow custom names for Pipfile and Pipfile.lock
61+
if $# -eq 2; then
62+
mv $1 Pipfile
63+
mv $2 Pipfile.lock
64+
fi
6065
if ! pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}"; then
6166
echo "Failed to install ${package_name} with version ${CODEFLARE_RELEASE_VERSION} in $dir"
6267
exit 1
@@ -71,6 +76,10 @@ jobs:
7176
echo "Failed to remove virtual environment"
7277
exit 1
7378
fi
79+
if $# -eq 2; then
80+
mv Pipfile $1
81+
mv Pipfile.lock $2
82+
fi
7483
}
7584
# Get the list of available versions for the package
7685
if ! versions=$(pipenv run pip-versions list $package_name);then
@@ -81,31 +90,8 @@ jobs:
8190
if echo "$versions" | grep -q "${CODEFLARE_RELEASE_VERSION}"; then
8291
echo "Version ${CODEFLARE_RELEASE_VERSION} is available for $package_name"
8392
# list all Pipfile paths having Codeflare-SDK listed
84-
paths+=($(grep -rl "${package_name} = \"~=.*\""))
85-
# Extracting only directories from file paths, excluding a `.gitworkflow` directory
86-
directories=()
87-
exclude_directories=(
88-
".git/objects/pack"
89-
".github/workflows/",
90-
)
91-
for path in "${paths[@]}"; do
92-
current_dir=$(dirname "$path")
93-
#Check if current_dir is not in exclude_directories list
94-
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
95-
#Check if Pipfile exists in current_dir
96-
if ls "$current_dir"/Pipfile* 1> /dev/null 2>&1;then
97-
directories+=("$current_dir")
98-
fi
99-
fi
100-
done
101-
# Remove duplicates
102-
directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
103-
# Print the directories for verification
104-
echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
105-
for dir in "${directories[@]}"; do
106-
echo "- $dir"
107-
done
108-
# iterate over the directories and update Pipfile
93+
# Extracting only directories from file paths, excluding a `.gitworkflow` and `.git` directory
94+
directories+=($(grep --exclude-dir=.git --exclude-dir=.github --include="Pipfile*" -rl "${package_name} = \"~=.*\"" | xargs dirname | sort | uniq))
10995
counter=0
11096
total=${#directories[@]}
11197
for dir in "${directories[@]}"; do
@@ -126,20 +112,10 @@ jobs:
126112
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
127113
if ! [ -f "Pipfile" ]; then
128114
if [ -f "Pipfile.cpu" ]; then
129-
mv Pipfile.cpu Pipfile
130-
mv Pipfile.lock.cpu Pipfile.lock
131-
#install specified package
132-
install_package_using_pipenv
133-
mv Pipfile.lock Pipfile.lock.cpu
134-
mv Pipfile Pipfile.cpu
115+
install_package_using_pipenv Pipfile.cpu Pipfile.lock.cpu
135116
fi
136117
if [ -f "Pipfile.gpu" ]; then
137-
mv Pipfile.gpu Pipfile
138-
mv Pipfile.lock.gpu Pipfile.lock
139-
#install specified package
140-
install_package_using_pipenv
141-
mv Pipfile.lock Pipfile.lock.gpu
142-
mv Pipfile Pipfile.gpu
118+
install_package_using_pipenv Pipfile.gpu Pipfile.lock.gpu
143119
fi
144120
else
145121
#install specified package

0 commit comments

Comments
 (0)