Skip to content

Commit 448196c

Browse files
authored
Merge pull request #662 from Kaggle/add-diff-base-flag
Add --base flag to diff script
2 parents e531377 + dcf1c43 commit 448196c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

diff

+19-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ Compare a given Docker image package versions against the prod image.
88
99
Options:
1010
-g, --gpu Compare GPU images.
11-
-t, --target The image to diff against the prod image.
11+
-b, --base The base image to diff against.
12+
-t, --target The image to diff against the base image.
1213
Default is the locally built image.
1314
EOF
1415
}
1516

1617

1718
BASE_IMAGE_TAG='gcr.io/kaggle-images/python:latest'
19+
BASE_IMAGE_TAG_OVERRIDE=''
1820
TARGET_IMAGE_TAG='kaggle/python-build'
1921
TARGET_IMAGE_TAG_OVERRIDE=''
2022

@@ -28,6 +30,15 @@ while :; do
2830
BASE_IMAGE_TAG='gcr.io/kaggle-private-byod/python:latest'
2931
TARGET_IMAGE_TAG='kaggle/python-gpu-build'
3032
;;
33+
-b|--base)
34+
if [[ -z "$2" ]]; then
35+
usage
36+
printf 'ERROR: No IMAGE specified after the %s flag.\n' "$1" >&2
37+
exit
38+
fi
39+
BASE_IMAGE_TAG_OVERRIDE="$2"
40+
shift # skip the flag value
41+
;;
3142
-t|--target)
3243
if [[ -z "$2" ]]; then
3344
usage
@@ -49,6 +60,10 @@ while :; do
4960
shift
5061
done
5162

63+
if [[ -n "$BASE_IMAGE_TAG_OVERRIDE" ]]; then
64+
BASE_IMAGE_TAG="$BASE_IMAGE_TAG_OVERRIDE"
65+
fi
66+
5267
if [[ -n "$TARGET_IMAGE_TAG_OVERRIDE" ]]; then
5368
TARGET_IMAGE_TAG="$TARGET_IMAGE_TAG_OVERRIDE"
5469
fi
@@ -59,7 +74,9 @@ readonly TARGET_IMAGE_TAG
5974
echo "Base: $BASE_IMAGE_TAG"
6075
echo "Target: $TARGET_IMAGE_TAG"
6176

62-
docker pull "$BASE_IMAGE_TAG"
77+
if [[ "$BASE_IMAGE_TAG" == "gcr.io/"* ]]; then
78+
docker pull "$BASE_IMAGE_TAG"
79+
fi
6380

6481
CMDS=('dpkg-query --show -f "${Package}==${Version}\n"' 'pip freeze')
6582
for cmd in "${CMDS[@]}"; do

0 commit comments

Comments
 (0)