|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2021 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# |
| 18 | +# A smoke test that installs TFMOT with `setup.py install` and then tries to |
| 19 | +# import it. |
| 20 | +# |
| 21 | + |
| 22 | +# Make Bash more strict, for easier debugging. |
| 23 | +set -e # Exit on the first error. |
| 24 | +set -u # Treat unset variables as error. |
| 25 | +set -o pipefail # Treat the failure of a command in a pipeline as error. |
| 26 | + |
| 27 | +# Display commands being run. |
| 28 | +# WARNING: please only enable 'set -x' if necessary for debugging, and be very |
| 29 | +# careful if you handle credentials (e.g. from Keystore) with 'set -x': |
| 30 | +# statements like "export VAR=$(cat /tmp/keystore/credentials)" will result in |
| 31 | +# the credentials being printed in build logs. |
| 32 | +# Additionally, recursive invocation with credentials as command-line |
| 33 | +# parameters, will print the full command, with credentials, in the build logs. |
| 34 | +# set -x |
| 35 | + |
| 36 | + |
| 37 | +# Create an isolated Python environment. |
| 38 | +mkdir venv |
| 39 | +virtualenv ./venv |
| 40 | +source ./venv/bin/activate |
| 41 | + |
| 42 | +# Install Tensorflow, then TFMOT from source. |
| 43 | +pip install tensorflow |
| 44 | +pip install --requirement "requirements.txt" |
| 45 | +python setup.py install |
| 46 | + |
| 47 | +# Go to another directory and try to import TFMOT. |
| 48 | +mkdir /tmp/my_project |
| 49 | +pushd /tmp/my_project |
| 50 | +python -c "import tensorflow_model_optimization" |
0 commit comments