parent
5215b322c1
commit
87cc788e1c
@ -147,7 +147,6 @@ tensorflow/third_party/systemlibs/cython.BUILD
|
||||
tensorflow/third_party/systemlibs/double_conversion.BUILD
|
||||
tensorflow/third_party/systemlibs/zlib.BUILD
|
||||
tensorflow/third_party/systemlibs/jsoncpp.BUILD
|
||||
tensorflow/third_party/systemlibs/enum34.BUILD
|
||||
tensorflow/third_party/systemlibs/re2.BUILD
|
||||
tensorflow/third_party/systemlibs/lmdb.BUILD
|
||||
tensorflow/third_party/systemlibs/googleapis.BUILD
|
||||
@ -213,6 +212,7 @@ tensorflow/third_party/git/BUILD.tpl
|
||||
tensorflow/third_party/git/BUILD
|
||||
tensorflow/third_party/git/git_configure.bzl
|
||||
tensorflow/third_party/protobuf/BUILD
|
||||
tensorflow/third_party/enum34.BUILD
|
||||
tensorflow/third_party/tflite_mobilenet.BUILD
|
||||
tensorflow/third_party/py/BUILD
|
||||
tensorflow/third_party/py/BUILD.tpl
|
||||
|
@ -214,6 +214,7 @@ py_library(
|
||||
":pywrap_tensorflow",
|
||||
":util",
|
||||
"//tensorflow/core:protos_all_py",
|
||||
"@absl_py//absl:app",
|
||||
"@absl_py//absl/flags",
|
||||
"@six_archive//:six",
|
||||
],
|
||||
@ -234,7 +235,10 @@ py_library(
|
||||
name = "platform_test",
|
||||
srcs = ["platform/googletest.py"],
|
||||
srcs_version = "PY2AND3",
|
||||
deps = [":platform_benchmark"],
|
||||
deps = [
|
||||
":platform_benchmark",
|
||||
"@absl_py//absl/testing:absltest",
|
||||
],
|
||||
)
|
||||
|
||||
tf_py_test(
|
||||
|
@ -18,109 +18,23 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import errno as _errno
|
||||
import sys as _sys
|
||||
|
||||
from absl.app import run as _run
|
||||
|
||||
from tensorflow.python.platform import flags
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
def _usage(shorthelp):
|
||||
"""Writes __main__'s docstring to stdout with some help text.
|
||||
|
||||
Args:
|
||||
shorthelp: bool, if True, prints only flags from the main module,
|
||||
rather than all flags.
|
||||
"""
|
||||
doc = _sys.modules['__main__'].__doc__
|
||||
if not doc:
|
||||
doc = '\nUSAGE: %s [flags]\n' % _sys.argv[0]
|
||||
doc = flags.text_wrap(doc, indent=' ', firstline_indent='')
|
||||
else:
|
||||
# Replace all '%s' with sys.argv[0], and all '%%' with '%'.
|
||||
num_specifiers = doc.count('%') - 2 * doc.count('%%')
|
||||
try:
|
||||
doc %= (_sys.argv[0],) * num_specifiers
|
||||
except (OverflowError, TypeError, ValueError):
|
||||
# Just display the docstring as-is.
|
||||
pass
|
||||
if shorthelp:
|
||||
flag_str = flags.FLAGS.main_module_help()
|
||||
else:
|
||||
flag_str = str(flags.FLAGS)
|
||||
try:
|
||||
_sys.stdout.write(doc)
|
||||
if flag_str:
|
||||
_sys.stdout.write('\nflags:\n')
|
||||
_sys.stdout.write(flag_str)
|
||||
_sys.stdout.write('\n')
|
||||
except IOError as e:
|
||||
# We avoid printing a huge backtrace if we get EPIPE, because
|
||||
# "foo.par --help | less" is a frequent use case.
|
||||
if e.errno != _errno.EPIPE:
|
||||
raise
|
||||
|
||||
|
||||
class _HelpFlag(flags.BooleanFlag):
|
||||
"""Special boolean flag that displays usage and raises SystemExit."""
|
||||
NAME = 'help'
|
||||
SHORT_NAME = 'h'
|
||||
|
||||
def __init__(self):
|
||||
super(_HelpFlag, self).__init__(
|
||||
self.NAME, False, 'show this help', short_name=self.SHORT_NAME)
|
||||
|
||||
def parse(self, arg):
|
||||
if arg:
|
||||
_usage(shorthelp=True)
|
||||
print()
|
||||
print('Try --helpfull to get a list of all flags.')
|
||||
_sys.exit(1)
|
||||
|
||||
|
||||
class _HelpshortFlag(_HelpFlag):
|
||||
"""--helpshort is an alias for --help."""
|
||||
NAME = 'helpshort'
|
||||
SHORT_NAME = None
|
||||
|
||||
|
||||
class _HelpfullFlag(flags.BooleanFlag):
|
||||
"""Display help for flags in main module and all dependent modules."""
|
||||
|
||||
def __init__(self):
|
||||
super(_HelpfullFlag, self).__init__('helpfull', False, 'show full help')
|
||||
|
||||
def parse(self, arg):
|
||||
if arg:
|
||||
_usage(shorthelp=False)
|
||||
_sys.exit(1)
|
||||
|
||||
|
||||
_define_help_flags_called = False
|
||||
|
||||
|
||||
def _define_help_flags():
|
||||
global _define_help_flags_called
|
||||
if not _define_help_flags_called:
|
||||
flags.DEFINE_flag(_HelpFlag())
|
||||
flags.DEFINE_flag(_HelpfullFlag())
|
||||
flags.DEFINE_flag(_HelpshortFlag())
|
||||
_define_help_flags_called = True
|
||||
def _parse_flags_tolerate_undef(argv):
|
||||
"""Parse args, returning any unknown flags (ABSL defaults to crashing)."""
|
||||
return flags.FLAGS(_sys.argv if argv is None else argv, known_only=True)
|
||||
|
||||
|
||||
@tf_export(v1=['app.run'])
|
||||
def run(main=None, argv=None):
|
||||
"""Runs the program with an optional 'main' function and 'argv' list."""
|
||||
|
||||
# Define help flags.
|
||||
_define_help_flags()
|
||||
|
||||
# Parse known flags.
|
||||
argv = flags.FLAGS(_sys.argv if argv is None else argv, known_only=True)
|
||||
|
||||
main = main or _sys.modules['__main__'].main
|
||||
|
||||
# Call the main function, passing through any arguments
|
||||
# to the final program.
|
||||
_sys.exit(main(argv))
|
||||
|
||||
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
|
||||
|
@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
"""Imports unittest as a replacement for testing.pybase.googletest."""
|
||||
"""Imports absltest as a replacement for testing.pybase.googletest."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
@ -26,7 +26,7 @@ import tempfile
|
||||
|
||||
# go/tf-wildcard-import
|
||||
# pylint: disable=wildcard-import
|
||||
from unittest import *
|
||||
from absl.testing.absltest import *
|
||||
# pylint: enable=wildcard-import
|
||||
|
||||
from tensorflow.python.framework import errors
|
||||
@ -41,7 +41,7 @@ from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
Benchmark = benchmark.TensorFlowBenchmark # pylint: disable=invalid-name
|
||||
|
||||
unittest_main = main
|
||||
absltest_main = main
|
||||
|
||||
# We keep a global variable in this module to make sure we create the temporary
|
||||
# directory only once per test binary invocation.
|
||||
@ -51,7 +51,7 @@ _googletest_temp_dir = ''
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: disable=undefined-variable
|
||||
def g_main(argv):
|
||||
"""Delegate to unittest.main after redefining testLoader."""
|
||||
"""Delegate to absltest.main after redefining testLoader."""
|
||||
if 'TEST_SHARD_STATUS_FILE' in os.environ:
|
||||
try:
|
||||
f = None
|
||||
@ -67,7 +67,7 @@ def g_main(argv):
|
||||
|
||||
if ('TEST_TOTAL_SHARDS' not in os.environ or
|
||||
'TEST_SHARD_INDEX' not in os.environ):
|
||||
return unittest_main(argv=argv)
|
||||
return absltest_main(argv=argv)
|
||||
|
||||
total_shards = int(os.environ['TEST_TOTAL_SHARDS'])
|
||||
shard_index = int(os.environ['TEST_SHARD_INDEX'])
|
||||
@ -87,7 +87,7 @@ def g_main(argv):
|
||||
# Override getTestCaseNames
|
||||
base_loader.getTestCaseNames = getShardedTestCaseNames
|
||||
|
||||
unittest_main(argv=argv, testLoader=base_loader)
|
||||
absltest_main(argv=argv, testLoader=base_loader)
|
||||
|
||||
|
||||
# Redefine main to allow running benchmarks
|
||||
|
@ -146,7 +146,11 @@ filegroup(
|
||||
"//third_party/eigen3:LICENSE",
|
||||
"//third_party/fft2d:LICENSE",
|
||||
"//third_party/hadoop:LICENSE.txt",
|
||||
"@absl_py//absl:LICENSE",
|
||||
"@absl_py//absl/logging:LICENSE",
|
||||
"@absl_py//absl/flags:LICENSE",
|
||||
"@absl_py//absl/testing:LICENSE",
|
||||
"@absl_py//absl/third_party/unittest3_backport:LICENSE",
|
||||
"@arm_neon_2_x86_sse//:LICENSE",
|
||||
"@astor_archive//:LICENSE",
|
||||
"@boringssl//:LICENSE",
|
||||
@ -155,6 +159,7 @@ filegroup(
|
||||
"@curl//:COPYING",
|
||||
"@double_conversion//:LICENSE",
|
||||
"@eigen_archive//:COPYING.MPL2",
|
||||
"@enum34_archive//:LICENSE",
|
||||
"@farmhash_archive//:COPYING",
|
||||
"@fft2d//:fft/readme.txt",
|
||||
"@flatbuffers//:LICENSE.txt",
|
||||
|
@ -337,7 +337,8 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
|
||||
"https://pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz",
|
||||
],
|
||||
sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1",
|
||||
build_file = clean_dep("//third_party/systemlibs:enum34.BUILD"),
|
||||
build_file = clean_dep("//third_party:enum34.BUILD"),
|
||||
strip_prefix = "enum34-1.1.6/enum",
|
||||
)
|
||||
|
||||
tf_http_archive(
|
||||
|
@ -7,7 +7,7 @@ exports_files(["LICENSE"])
|
||||
|
||||
py_library(
|
||||
name = "enum",
|
||||
srcs = ["enum34-1.1.6/enum/__init__.py"],
|
||||
srcs = ["__init__.py"],
|
||||
srcs_version = "PY2AND3",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
Loading…
Reference in New Issue
Block a user