diff --git a/tensorflow_probability/python/distributions/two_piece_normal.py b/tensorflow_probability/python/distributions/two_piece_normal.py index 73faabff4c..2c3b33138b 100644 --- a/tensorflow_probability/python/distributions/two_piece_normal.py +++ b/tensorflow_probability/python/distributions/two_piece_normal.py @@ -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 diff --git a/testing/get_github_changed_py_files.sh b/testing/get_github_changed_py_files.sh new file mode 100755 index 0000000000..16a2d14178 --- /dev/null +++ b/testing/get_github_changed_py_files.sh @@ -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 diff --git a/testing/install_test_dependencies.sh b/testing/install_test_dependencies.sh index 335627f37c..e16e7c33d3 100755 --- a/testing/install_test_dependencies.sh +++ b/testing/install_test_dependencies.sh @@ -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() { diff --git a/testing/run_github_lints.sh b/testing/run_github_lints.sh index 77efafb86b..490514e40e 100755 --- a/testing/run_github_lints.sh +++ b/testing/run_github_lints.sh @@ -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} diff --git a/testing/run_github_tests.sh b/testing/run_github_tests.sh index f986a209d7..e79d11da97 100755 --- a/testing/run_github_tests.sh +++ b/testing/run_github_tests.sh @@ -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 @@ -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/...))"