Skip to content

Commit

Permalink
script to update python versions in docs, Makefiles and notebooks aut…
Browse files Browse the repository at this point in the history
…omatically
  • Loading branch information
ukclivecox committed Nov 9, 2018
1 parent c646c52 commit 0f31846
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions wrappers/s2i/python/update_python_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

STARTUP_DIR="$( cd "$( dirname "$0" )" && pwd )"

This comment has been minimized.

Copy link
@RafalSkolasinski

RafalSkolasinski Jan 14, 2020

Contributor

Wouldn't just STARTUP_DIR="$PWD" be good enough?

This comment has been minimized.

Copy link
@adriangonz

adriangonz Jan 14, 2020

Contributor

I think that if you were to run the script from a different folder (e.g. like ../../../home/something/wrappers/s2i/python/update_python_version.sh), then pwd would show the path of that folder instead of /wrappers/s2i/python.

This is a way to make sure that the current working folder is always where the update_python_version.sh script lives.

This comment has been minimized.

Copy link
@RafalSkolasinski

RafalSkolasinski Jan 14, 2020

Contributor

Fair enough, that makes total sense. Thanks Adrian!


if [ "$#" -ne 2 ]; then
echo "You must enter <existing-python-version> <new-python-version>"
exit 1
fi

OLD_VERSION=$1
NEW_VERSION=$2

declare -a paths=('./examples/*.ipynb' './docs/*.md' './example/*Makefile' './integrations/*Makefile')
declare -a versions=('2' '3' '36' '37')

cd ../../..

for i in "${paths[@]}"
do
for PYTHON_VERSION in "${versions[@]}"
do
echo "Updating python version ${PYTHON_VERSION} in $i from ${OLD_VERSION} to ${NEW_VERSION}"
find . -type f -path "$i" -exec grep -l seldon-core-s2i-python${PYTHON_VERSION}:${OLD_VERSION} \{\} \; | xargs -n1 -r sed -i "s/seldon-core-s2i-python${PYTHON_VERSION}:${OLD_VERSION}/seldon-core-s2i-python${PYTHON_VERSION}:${NEW_VERSION}/g"
done
done



0 comments on commit 0f31846

Please sign in to comment.