forked from horovod/horovod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert-package-versions.sh
executable file
·59 lines (52 loc) · 1.34 KB
/
assert-package-versions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -euo pipefail
result=0
for var in TENSORFLOW_PACKAGE KERAS_PACKAGE PYTORCH_PACKAGE PYTORCH_LIGHTNING_PACKAGE TORCHVISION_PACKAGE MXNET_PACKAGE PYSPARK_PACKAGE
do
if [ -z "${!var-}" ]
then
echo -e "$var \u001b[31mnot set\u001b[0m"
result=1
continue
fi
pattern="${!var}"
if [ "$pattern" == "None" ]
then
continue
elif [[ "$pattern" == "tf-nightly" ]]
then
flag="-P"
pattern="$pattern==.*\\.dev20\\d{6}"
elif [[ "$pattern" == "torch-nightly"* ]] ||
[[ "$pattern" == "torchvision" ]]
then
flag="-P"
pattern="${pattern/-nightly*/}==.*\\.dev20\\d{6}.*"
elif [[ "$pattern" == "mxnet-nightly"* ]]
then
flag="-P"
pattern="${pattern/-nightly/}==.*20\\d{6}"
else
flag="-Fx"
fi
found=$(pip freeze | grep -i $flag "$pattern" || true)
if [ -n "$found" ]
then
if [ "$found" == "$pattern" ]
then
echo -e "$found \u001b[32mfound\u001b[0m"
else
echo -e "$found \u001b[32mfound\u001b[0m (matches ${!var} / $pattern)"
fi
else
found=$(pip freeze | grep -i "^${pattern/=*/==}" || true)
if [ -n "$found" ]
then
echo -e "$found \u001b[31mfound BUT\u001b[0m ${!var} / $pattern \u001b[31mexpected\u001b[0m"
else
echo -e "$pattern \u001b[31mNOT found\u001b[0m (no match for ${!var} / $pattern)"
fi
result=1
fi
done
exit $result