Skip to content

Commit 762e4bb

Browse files
orionrwchargin
authored andcommitted
Add separate non-TensorFlow test run in Travis CI (#2075)
This adds support for smoke testing the Pip package without TensorFlow installed, and adds selected tests to a new no-TF Travis configuration. Tests should be tagged `support_notf` to run under this build.
1 parent 4c5e3f3 commit 762e4bb

File tree

5 files changed

+62
-26
lines changed

5 files changed

+62
-26
lines changed

.travis.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ env:
2626
matrix:
2727
- TF_VERSION_ID=tf-nightly
2828
- TF_VERSION_ID=tf-nightly-2.0-preview
29+
- TF_VERSION_ID= # Do not install TensorFlow in this case
2930

3031
cache:
3132
directories:
@@ -104,7 +105,15 @@ install:
104105
- pip install mock==2.0.0
105106
- pip install moto==1.3.7
106107
- pip install yamllint==1.5.0
107-
- pip install -I "${TF_VERSION_ID}"
108+
- |
109+
# Install TensorFlow if requested
110+
if [ -n "${TF_VERSION_ID}" ]; then
111+
pip install -I "${TF_VERSION_ID}"
112+
else
113+
# Requirements typically found through TensorFlow
114+
pip install "absl-py>=0.7.0"
115+
pip install "numpy<2.0,>=1.14.5"
116+
fi
108117
109118
before_script:
110119
# fail the build if there are Python syntax errors or undefined names
@@ -127,7 +136,14 @@ script:
127136
# Note: bazel test implies fetch+build, but this gives us timing.
128137
- bazel fetch //tensorboard/...
129138
- bazel build //tensorboard/...
130-
- bazel test //tensorboard/...
139+
- |
140+
# When TensorFlow is not installed, run a restricted subset of tests.
141+
if [ -z "${TF_VERSION_ID}" ]; then
142+
test_tag_filters=support_notf
143+
else
144+
test_tag_filters=
145+
fi
146+
- bazel test //tensorboard/... --test_tag_filters="${test_tag_filters}"
131147
# Run manual S3 test
132148
- bazel test //tensorboard/compat/tensorflow_stub:gfile_s3_test
133149
- bazel run //tensorboard/pip_package:build_pip_package -- --tf-version "${TF_VERSION_ID}" --smoke

tensorboard/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ py_test(
5252
srcs = ["lib_test.py"],
5353
srcs_version = "PY2AND3",
5454
visibility = ["//tensorboard:internal"],
55+
tags = ["support_notf"],
5556
deps = [
5657
":lib",
5758
"@org_pythonhosted_six",
@@ -366,6 +367,7 @@ py_test(
366367
srcs = ["lazy_test.py"],
367368
srcs_version = "PY2AND3",
368369
size = "small",
370+
tags = ["support_notf"],
369371
deps = [
370372
":lazy",
371373
"@org_pythonhosted_six",

tensorboard/compat/tensorflow_stub/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ py_test(
3131
size = "small",
3232
srcs = ["io/gfile_test.py"],
3333
srcs_version = "PY2AND3",
34+
tags = ["support_notf"],
3435
deps = [
3536
":tensorflow_stub",
3637
],

tensorboard/pip_package/build_pip_package.sh

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,23 @@ smoke() {
125125
smoke_tf="$2"
126126
set +x
127127
printf '\n\n%70s\n' | tr ' ' '='
128-
echo "Smoke testing with ${smoke_python} and ${smoke_tf}..."
128+
if [ -z "${smoke_tf}" ]; then
129+
echo "Smoke testing with ${smoke_python} and no tensorflow..."
130+
export TENSORBOARD_NO_TF=1
131+
else
132+
echo "Smoke testing with ${smoke_python} and ${smoke_tf}..."
133+
fi
129134
printf '\n'
130135
set -x
131136
command -v "${smoke_python}" >/dev/null
132137
virtualenv -qp "${smoke_python}" "${smoke_venv}"
133138
cd "${smoke_venv}"
134139
. bin/activate
135140
pip install -qU pip
136-
pip install -qU "${smoke_tf}"
141+
142+
if [ -n "${smoke_tf}" ]; then
143+
pip install -qU "${smoke_tf}"
144+
fi
137145
pip install -qU ../dist/*"py${py_major_version}"*.whl >/dev/null
138146
pip freeze # Log the results of pip installation
139147

@@ -153,32 +161,40 @@ smoke() {
153161
python -c "
154162
import tensorboard as tb
155163
assert tb.__version__ == tb.version.VERSION
156-
tb.summary.scalar_pb('test', 42)
157164
from tensorboard.plugins.projector import visualize_embeddings
158-
from tensorboard.plugins.beholder import Beholder, BeholderHook
159165
tb.notebook.start # don't invoke; just check existence
160166
"
167+
if [ -n "${smoke_tf}" ]; then
168+
# Only test summary scalar and beholder with TF
169+
python -c "
170+
import tensorboard as tb
171+
tb.summary.scalar_pb('test', 42)
172+
from tensorboard.plugins.beholder import Beholder, BeholderHook
173+
"
174+
fi
161175

162-
# Exhaustively test various sequences of importing tf.summary.
163-
test_tf_summary() {
164-
# First argument is subpath to test, e.g. '' or '.compat.v2'.
165-
import_attr="import tensorflow as tf; a = tf${1}.summary; a.write; a.scalar"
166-
import_as="import tensorflow${1}.summary as b; b.write; b.scalar"
167-
import_from="from tensorflow${1} import summary as c; c.write; c.scalar"
168-
printf '%s\n' "${import_attr}" "${import_as}" "${import_from}" | python -
169-
printf '%s\n' "${import_attr}" "${import_from}" "${import_as}" | python -
170-
printf '%s\n' "${import_as}" "${import_attr}" "${import_from}" | python -
171-
printf '%s\n' "${import_as}" "${import_from}" "${import_attr}" | python -
172-
printf '%s\n' "${import_from}" "${import_attr}" "${import_as}" | python -
173-
printf '%s\n' "${import_from}" "${import_as}" "${import_attr}" | python -
174-
}
175-
test_tf_summary '.compat.v2'
176-
is_tf_2() {
177-
python -c "import tensorflow as tf; assert tf.__version__[:2] == '2.'" \
178-
>/dev/null 2>&1
179-
}
180-
if is_tf_2 ; then
181-
test_tf_summary ''
176+
if [ -n "${smoke_tf}" ]; then
177+
# Exhaustively test various sequences of importing tf.summary.
178+
test_tf_summary() {
179+
# First argument is subpath to test, e.g. '' or '.compat.v2'.
180+
import_attr="import tensorflow as tf; a = tf${1}.summary; a.write; a.scalar"
181+
import_as="import tensorflow${1}.summary as b; b.write; b.scalar"
182+
import_from="from tensorflow${1} import summary as c; c.write; c.scalar"
183+
printf '%s\n' "${import_attr}" "${import_as}" "${import_from}" | python -
184+
printf '%s\n' "${import_attr}" "${import_from}" "${import_as}" | python -
185+
printf '%s\n' "${import_as}" "${import_attr}" "${import_from}" | python -
186+
printf '%s\n' "${import_as}" "${import_from}" "${import_attr}" | python -
187+
printf '%s\n' "${import_from}" "${import_attr}" "${import_as}" | python -
188+
printf '%s\n' "${import_from}" "${import_as}" "${import_attr}" | python -
189+
}
190+
test_tf_summary '.compat.v2'
191+
is_tf_2() {
192+
python -c "import tensorflow as tf; assert tf.__version__[:2] == '2.'" \
193+
>/dev/null 2>&1
194+
}
195+
if is_tf_2 ; then
196+
test_tf_summary ''
197+
fi
182198
fi
183199

184200
deactivate

tensorboard/summary/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ py_test(
8181
size = "small",
8282
srcs = ["summary_test.py"],
8383
srcs_version = "PY2AND3",
84+
tags = ["support_notf"],
8485
deps = [
8586
":summary",
8687
":summary_v1",

0 commit comments

Comments
 (0)