Skip to content

Commit 14a642c

Browse files
craymichaelfacebook-github-bot
authored andcommitted
Test against multiple version of transformers library (#1362)
Summary: Pull Request resolved: #1362 On OSS, test against multiple versions of transformers library. Versions selected based on caching logic changes between versions, as well as the newest version. Reviewed By: cyrjano Differential Revision: D64075428 fbshipit-source-id: 8d75e8caabf96232d6a3c8cd9b174a849f3d7391
1 parent bacac27 commit 14a642c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/workflows/test-pip-cpu.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
pytorch_args: ["-v 1.10", "-v 1.11", "-v 1.12", "-v 1.13", "-v 2.0.0", "-v 2.1.0", "-v 2.2.0", "-v 2.3.0"]
16+
transformers_args: ["-t 4.38.0", "-t 4.39.0", "-t 4.41.0", "-t 4.43.0", "-t 4.45.2"]
1617
docker_img: ["cimg/python:3.8", "cimg/python:3.9", "cimg/python:3.10", "cimg/python:3.11"]
1718
exclude:
1819
- pytorch_args: "-v 1.10"
@@ -31,6 +32,6 @@ jobs:
3132
repository: pytorch/captum
3233
script: |
3334
sudo chmod -R 777 .
34-
./scripts/install_via_pip.sh ${{ matrix.pytorch_args }}
35+
./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} ${{ matrix.transformers_args }}
3536
# Run Tests
3637
python3 -m pytest -ra --cov=. --cov-report term-missing

scripts/install_via_pip.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ set -e
55
PYTORCH_NIGHTLY=false
66
DEPLOY=false
77
CHOSEN_TORCH_VERSION=-1
8+
CHOSEN_TRANSFORMERS_VERSION=-1
89

9-
while getopts 'ndfv:' flag; do
10+
while getopts 'ndfv:t:' flag; do
1011
case "${flag}" in
1112
n) PYTORCH_NIGHTLY=true ;;
1213
d) DEPLOY=true ;;
1314
f) FRAMEWORKS=true ;;
1415
v) CHOSEN_TORCH_VERSION=${OPTARG};;
15-
*) echo "usage: $0 [-n] [-d] [-f] [-v version]" >&2
16+
t) CHOSEN_TRANSFORMERS_VERSION=${OPTARG};;
17+
*) echo "usage: $0 [-n] [-d] [-f] [-v version] [-t transformers_version]" >&2
1618
exit 1 ;;
1719
esac
1820
done
@@ -66,4 +68,10 @@ if [[ $DEPLOY == true ]]; then
6668
pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off
6769
fi
6870

69-
pip install transformers --progress-bar off
71+
# install appropriate transformers version
72+
# If no version is specified, upgrade to the latest release.
73+
if [[ $CHOSEN_TRANSFORMERS_VERSION == -1 ]]; then
74+
pip install --upgrade transformers --progress-bar off
75+
else
76+
pip install transformers=="$CHOSEN_TRANSFORMERS_VERSION" --progress-bar off
77+
fi

0 commit comments

Comments
 (0)