Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""The Two-Piece Normal distribution class."""
"""The really Two-Piece Normal distribution class."""

# Dependency imports
import numpy as np
Expand Down
26 changes: 26 additions & 0 deletions testing/get_github_changed_py_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

set -v # print commands as they are executed
set -e # fail and exit on any command erroring

if [ $GITHUB_BASE_REF ]; then
# git fetch origin ${GITHUB_BASE_REF} --depth=1
git diff \
--name-only \
--diff-filter=AM origin/${GITHUB_BASE_REF} \
| { grep '^tensorflow_probability.*\.py$' || true; }
fi
4 changes: 3 additions & 1 deletion testing/install_test_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ else
fi

has_tensorflow_packages() {
python -m pip list | grep -v tensorflow-metadata | grep tensorflow &> /dev/null
python -m pip list \
| grep -v tensorflow-metadata \
| grep -v tensorflow-io-gcs-filesystem | grep tensorflow &> /dev/null
}

has_tf_nightly_cpu_package() {
Expand Down
12 changes: 2 additions & 10 deletions testing/run_github_lints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@
set -v # print commands as they are executed
set -e # fail and exit on any command erroring

get_changed_py_files() {
if [ $GITHUB_BASE_REF ]; then
git fetch origin ${GITHUB_BASE_REF} --depth=1
git diff \
--name-only \
--diff-filter=AM origin/${GITHUB_BASE_REF} \
| { grep '^tensorflow_probability.*\.py$' || true; }
fi
}
DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)

python -m pip install --upgrade 'pip>=19.2'
python -m pip install --upgrade setuptools
python -m pip install --quiet pylint

# Run lints on added/changed python files.
changed_py_files=$(get_changed_py_files)
changed_py_files=$(${DIR}/get_github_changed_py_files.sh)
if [[ -n "${changed_py_files}" ]]; then
echo "Running pylint on ${changed_py_files}"
pylint -j2 --rcfile=testing/pylintrc ${changed_py_files}
Expand Down
25 changes: 18 additions & 7 deletions testing/run_github_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ set -u # fail and exit on any undefined variable reference
DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)

# Make sure the environment variables are set.
if [ -z "${SHARD}" ]; then
if [ -z "${SHARD+x}" ]; then
echo "SHARD is unset."
exit -1
fi

if [ -z "${NUM_SHARDS}" ]; then
if [ -z "${NUM_SHARDS+x}" ]; then
echo "NUM_SHARDS is unset."
exit -1
fi
Expand Down Expand Up @@ -59,16 +59,27 @@ install_python_packages() {
which bazel || install_bazel
install_python_packages

# You can alter this test_target to some smaller subset of TFP tests in case
# you need to reproduce something on the CI workers.
test_target="//tensorflow_probability/..."
test_tags_to_skip="(gpu|requires-gpu-nvidia|notap|no-oss-ci|tfp_jax|tf2-broken|tf2-kokoro-broken)"
changed_py_files="$(${DIR}/get_github_changed_py_files.sh | \
sed -r 's#(.*)/([^/]+).py#//\1:\2.py#')"

if [[ -n "${changed_py_files}" ]]; then
test_targets=$(bazel query --universe_scope=//tensorflow_probability/... \
"tests(allrdeps(set(${changed_py_files})))")
else
# For pushes, test all targets.
test_targets=$(bazel query 'tests(//tensorflow_probability/...)')
fi

test_targets=$(echo "${test_targets}" | tr -s '\n' ' ')
test_targets="$(echo "${test_targets}" | sed -r 's#(.*) #\1#')"
test_tags_to_skip="(gpu|requires-gpu-nvidia|notap|no-oss-ci|tfp_jax|\
tfp_numpy|tf2-broken|tf2-kokoro-broken)"

# Given a test size (small, medium, large), a number of shards and a shard ID,
# query and print a list of tests of the given size to run in the given shard.
query_and_shard_tests_by_size() {
size=$1
bazel_query="attr(size, ${size}, tests(${test_target})) \
bazel_query="attr(size, ${size}, set(${test_targets})) \
except \
attr(tags, \"${test_tags_to_skip}\", \
tests(//tensorflow_probability/...))"
Expand Down