From eaec1ff04621b81d3806d7af32e8d1d953dd6277 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac <mihaimaruseac@google.com> Date: Thu, 5 Nov 2020 10:42:43 -0800 Subject: [PATCH] Remove `do_check_futures_test` from sanity CI PiperOrigin-RevId: 340883417 Change-Id: I0acf808df671ed7f56284b7a43148f8200202774 --- tensorflow/tools/ci_build/ci_sanity.sh | 9 +- tensorflow/tools/test/check_futures_test.py | 110 -------------------- 2 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 tensorflow/tools/test/check_futures_test.py diff --git a/tensorflow/tools/ci_build/ci_sanity.sh b/tensorflow/tools/ci_build/ci_sanity.sh index fca6df53dbb..1b138a41b09 100755 --- a/tensorflow/tools/ci_build/ci_sanity.sh +++ b/tensorflow/tools/ci_build/ci_sanity.sh @@ -586,11 +586,6 @@ do_check_load_py_test() { python check_load_py_test.py } -do_check_futures_test() { - cd "$ROOT_DIR/tensorflow/tools/test" - python check_futures_test.py -} - do_check_file_name_test() { cd "$ROOT_DIR/tensorflow/tools/test" python file_name_test.py @@ -663,8 +658,8 @@ do_configure_test() { } # Supply all sanity step commands and descriptions -SANITY_STEPS=("do_configure_test" "do_pylint" "do_check_futures_test" "do_buildifier" "do_bazel_nobuild" "do_bazel_deps_query" "do_pip_package_licenses_check" "do_lib_package_licenses_check" "do_java_package_licenses_check" "do_pip_smoke_test" "do_check_load_py_test" "do_code_link_check" "do_check_file_name_test" "do_pip_no_cuda_deps_check_ubuntu" "do_pip_no_cuda_deps_check_windows") -SANITY_STEPS_DESC=("Run ./configure" "Python 3 pylint" "Check that python files have certain __future__ imports" "buildifier check" "bazel nobuild" "bazel query" "pip: license check for external dependencies" "C library: license check for external dependencies" "Java Native Library: license check for external dependencies" "Pip Smoke Test: Checking py_test dependencies exist in pip package" "Check load py_test: Check that BUILD files with py_test target properly load py_test" "Code Link Check: Check there are no broken links" "Check file names for cases" "Check Ubuntu gpu pip package does not depend on cuda shared libraries" "Check Windows gpu pip package does not depend on cuda shared libraries") +SANITY_STEPS=("do_configure_test" "do_pylint" "do_buildifier" "do_bazel_nobuild" "do_bazel_deps_query" "do_pip_package_licenses_check" "do_lib_package_licenses_check" "do_java_package_licenses_check" "do_pip_smoke_test" "do_check_load_py_test" "do_code_link_check" "do_check_file_name_test" "do_pip_no_cuda_deps_check_ubuntu" "do_pip_no_cuda_deps_check_windows") +SANITY_STEPS_DESC=("Run ./configure" "Python 3 pylint" "buildifier check" "bazel nobuild" "bazel query" "pip: license check for external dependencies" "C library: license check for external dependencies" "Java Native Library: license check for external dependencies" "Pip Smoke Test: Checking py_test dependencies exist in pip package" "Check load py_test: Check that BUILD files with py_test target properly load py_test" "Code Link Check: Check there are no broken links" "Check file names for cases" "Check Ubuntu gpu pip package does not depend on cuda shared libraries" "Check Windows gpu pip package does not depend on cuda shared libraries") INCREMENTAL_FLAG="" DEFAULT_BAZEL_CONFIGS="" diff --git a/tensorflow/tools/test/check_futures_test.py b/tensorflow/tools/test/check_futures_test.py deleted file mode 100644 index 225986da9ae..00000000000 --- a/tensorflow/tools/test/check_futures_test.py +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2015 The TensorFlow Authors. All Rights Reserved. -# -# 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. -# ============================================================================== - -"""Check that TensorFlow python files have certain __future__ imports. - -This makes it easier to find Python 2.7 / Python 3.x incompatibility bugs. -In particular, this test makes it illegal to write a Python file that -doesn't import division from __future__, which can catch subtle division -bugs in Python 3. - -Note: We can't use tf.test in this file because it needs to run in an -environment that doesn't include license-free gen_blah_ops.py files. -""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import fnmatch -import os -import re - -import six - -BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) -FUTURES_PATTERN = re.compile(r'^from __future__ import (\w+)\s*$') -FUTURES_PATTERN_2 = re.compile( - r'^from __future__ import (\w+), (\w+), (\w+)\s*$') -FUTURES_PATTERN_3 = re.compile(r'^from __future__ import (\w+) as \w+\s*$') -REQUIRED_FUTURES = frozenset(['absolute_import', 'division', 'print_function']) - -ALLOWLIST = [ - 'python/platform/control_imports.py', - 'tools/docker/jupyter_notebook_config.py', - 'tools/ci_build/update_version.py', - 'tools/ci_build/copy_binary.py', -] - -# Tests that must *not* import division -OLD_DIVISION = [ - 'python/framework/tensor_shape_div_test.py', - 'python/kernel_tests/division_past_test.py', -] - - -def check_file(path, old_division): - futures = set() - count = 0 - for line in open(path) if six.PY2 else open(path, encoding='utf-8'): - count += 1 - m = FUTURES_PATTERN.match(line) - if not m: - m = FUTURES_PATTERN_3.match(line) - if m: - futures.add(m.group(1)) - else: - m = FUTURES_PATTERN_2.match(line) - if m: - for entry in m.groups(): - futures.add(entry) - if not count: - return # Skip empty files - if old_division: - # This file checks correct behavior without importing division - # from __future__, so make sure it's doing that. - expected = set(['absolute_import', 'print_function']) - if futures != expected: - raise AssertionError(('Incorrect futures for old_division file:\n' - ' expected = %s\n got = %s') % - (' '.join(expected), ' '.join(futures))) - else: - missing = REQUIRED_FUTURES - futures - if missing: - raise AssertionError('Missing futures: %s' % ' '.join(missing)) - - -def main(): - # Make sure BASE_DIR ends with tensorflow. If it doesn't, we probably - # computed the wrong directory. - if os.path.split(BASE_DIR)[-1] != 'tensorflow': - raise AssertionError("BASE_DIR = '%s' doesn't end with tensorflow" % - BASE_DIR) - - # Verify that all files have futures - allowlist = frozenset(os.path.join(BASE_DIR, w) for w in ALLOWLIST) - old_division = frozenset(os.path.join(BASE_DIR, w) for w in OLD_DIVISION) - for root, _, filenames in os.walk(BASE_DIR): - for f in fnmatch.filter(filenames, '*.py'): - path = os.path.join(root, f) - if path not in allowlist: - try: - check_file(path, old_division=path in old_division) - except AssertionError as e: - short_path = path[len(BASE_DIR) + 1:] - raise AssertionError('Error in %s: %s' % (short_path, str(e))) - - -if __name__ == '__main__': - main()