Automated rollback of commit 2af37fc088

PiperOrigin-RevId: 294270240
Change-Id: Ica2bb12e39eb53ee9604f6a5e7c05177cde2025e
This commit is contained in:
Gunhan Gulsoy 2020-02-10 11:51:21 -08:00 committed by TensorFlower Gardener
parent 00302ef285
commit 029c732c9a
7 changed files with 38 additions and 21 deletions

View File

@ -238,8 +238,8 @@ py_library(
":pywrap_tfe",
":util",
"//tensorflow/core:protos_all_py",
"@absl_py//absl:app",
"@absl_py//absl/flags",
"@rules_python//python/runfiles",
"@six_archive//:six",
],
)

View File

@ -18,8 +18,6 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import test_util
from tensorflow.python.framework import load_library
@ -33,8 +31,8 @@ from tensorflow.python.util import compat
class FileSystemTest(test.TestCase):
def setUp(self):
file_system_library = os.path.join(resource_loader.get_data_files_path(),
"test_file_system.so")
file_system_library = resource_loader.get_path_to_datafile(
"test_file_system.so")
load_library.load_file_system_library(file_system_library)
@test_util.run_deprecated_v1

View File

@ -33,9 +33,6 @@ from tensorflow.python.ops import variables
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import test
prefix_path = resource_loader.get_path_to_datafile(
'../../core/lib/jpeg/testdata')
class DecodeJpegBenchmark(test.Benchmark):
"""Evaluate tensorflow DecodeJpegOp performance."""
@ -66,7 +63,8 @@ class DecodeJpegBenchmark(test.Benchmark):
"""
ops.reset_default_graph()
image_file_path = os.path.join(prefix_path, image_name)
image_file_path = resource_loader.get_path_to_datafile(
os.path.join('core', 'lib', 'jpeg', 'testdata', image_name))
if tile is None:
image_content = variable_scope.get_variable(

View File

@ -28,12 +28,9 @@ import six
from tensorflow.python.framework import errors_impl
from tensorflow.python.lib.io import tf_record
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import test
from tensorflow.python.util import compat
prefix_path = resource_loader.get_path_to_datafile("../../../core/lib")
TFRecordCompressionType = tf_record.TFRecordCompressionType
# Edgar Allan Poe's 'Eldorado'

View File

@ -23,6 +23,13 @@ import sys as _sys
from tensorflow.python.util import tf_inspect as _inspect
from tensorflow.python.util.tf_export import tf_export
# pylint: disable=g-import-not-at-top
try:
from rules_python.python.runfiles import runfiles
except ImportError:
runfiles = None
# pylint: enable=g-import-not-at-top
@tf_export(v1=['resource_loader.load_resource'])
def load_resource(path):
@ -37,11 +44,7 @@ def load_resource(path):
Raises:
IOError: If the path is not found, or the resource can't be opened.
"""
tensorflow_root = (_os.path.join(
_os.path.dirname(__file__), _os.pardir, _os.pardir))
path = _os.path.join(tensorflow_root, path)
path = _os.path.abspath(path)
with open(path, 'rb') as f:
with open(get_path_to_datafile(path), 'rb') as f:
return f.read()
@ -113,8 +116,18 @@ def get_path_to_datafile(path):
Raises:
IOError: If the path is not found, or the resource can't be opened.
"""
data_files_path = _os.path.dirname(_inspect.getfile(_sys._getframe(1)))
return _os.path.join(data_files_path, path)
# First, try finding in the new path.
if runfiles:
r = runfiles.Create()
new_fpath = r.Rlocation(
_os.path.abspath(_os.path.join('tensorflow', path)))
if new_fpath is not None and _os.path.exists(new_fpath):
return new_fpath
# Then, the old style path, as people became dependent on this buggy call.
old_filepath = _os.path.join(
_os.path.dirname(_inspect.getfile(_sys._getframe(1))), path)
return old_filepath
@tf_export(v1=['resource_loader.readahead_file_path'])

View File

@ -79,8 +79,10 @@ _VERBOSE_DIFFS_HELP = """
false, only print which libraries have differences.
"""
_API_GOLDEN_FOLDER_V1 = resource_loader.get_path_to_datafile('../golden/v1')
_API_GOLDEN_FOLDER_V2 = resource_loader.get_path_to_datafile('../golden/v2')
_API_GOLDEN_FOLDER_V1 = os.path.join(
resource_loader.get_data_files_path(), '..', 'golden', 'v1')
_API_GOLDEN_FOLDER_V2 = os.path.join(
resource_loader.get_data_files_path(), '..', 'golden', 'v2')
_TEST_README_FILE = resource_loader.get_path_to_datafile('README.txt')
_UPDATE_WARNING_FILE = resource_loader.get_path_to_datafile(
'API_UPDATE_WARNING.txt')

View File

@ -904,6 +904,15 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
],
)
tf_http_archive(
name = "rules_python",
sha256 = "aa96a691d3a8177f3215b14b0edc9641787abaaa30363a080165d06ab65e1161",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
"https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
],
)
tf_http_archive(
name = "build_bazel_rules_android",
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",