Commit Graph

183 Commits

Author SHA1 Message Date
jma
421453ee0c updated docstring 2020-09-23 11:36:47 -07:00
TensorFlower Gardener
d365a03c9a Merge pull request from samikama:Transactions_part8
PiperOrigin-RevId: 323944140
Change-Id: I33073187fbd6cfb01e551381cf076455a1a3f841
2020-07-29 23:21:51 -07:00
Sami Kama
56aa1f7b58 Add Transactional API python bindings 2020-07-23 13:00:52 -07:00
Lukas Geiger
0257bcd418 Fix FileIO tests for Python < 3.6 2020-07-14 23:06:58 +02:00
Lukas Geiger
ca77c23bda Implement __next__ instead of next 2020-07-11 00:49:50 +02:00
TensorFlower Gardener
b5a50ac950 Merge pull request from lgeiger:fix-python35-test
PiperOrigin-RevId: 320624065
Change-Id: I4a95af39549380a4c7ff6cb861a197f44c9e34a5
2020-07-10 10:16:03 -07:00
Lukas Geiger
c36bc9b072 Fix FileIO test for Python < 3.6 2020-07-10 12:08:34 +02:00
TensorFlower Gardener
b91f0caa8e Merge pull request from lgeiger:gfile-pathlib
PiperOrigin-RevId: 320407557
Change-Id: I48a9a00d474d12e97d9ab45d598c8db3dab6f0cd
2020-07-09 12:25:05 -07:00
Lukas Geiger
5ef85fc6c8 Convert path to string right before passing it to the filesystem layer 2020-07-09 00:01:23 +02:00
Lukas Geiger
575632d3eb Support path-like objects in gfile.* 2020-07-08 03:06:02 +02:00
Lukas Geiger
b4ba1cc897 Support path-like objects in FileIO and GFile
[Path-like objects](https://docs.python.org/3/glossary.html#term-path-like-object) as used in [`pathlib`](https://docs.python.org/3.8/library/pathlib.html?highlight=pathlib#module-pathlib) are the recommended way to interact with file paths in Python. This PR changes `FileIO` to allow for path-like objects which would otherwise raise an exception when passed to `compat.as_bytes`.
`FileIO` and `GFile` emulate the API of [Python's builtin `open`](https://docs.python.org/3.8/library/functions.html#open) this possibility will be expected by users and should make switching between `open` and `GFile` easier.
2020-07-08 03:06:02 +02:00
Gaurav Jain
f618ab4955 Move away from deprecated asserts
- assertEquals -> assertEqual
- assertRaisesRegexp -> assertRegexpMatches
- assertRegexpMatches -> assertRegex

PiperOrigin-RevId: 319118081
Change-Id: Ieb457128522920ab55d6b69a7f244ab798a7d689
2020-06-30 16:10:22 -07:00
A. Unique TensorFlower
0bf070c54d Reacquire the GIL when handing errors in the read method of file_io's BufferedInputStream.
PiperOrigin-RevId: 316120310
Change-Id: I905e2c8652b977c154618c2e4d870dd2925a7234
2020-06-12 09:49:13 -07:00
Mihai Maruseac
b97bfb5d69 Prevent local directory traversal when GCS has a name starting with /.
PiperOrigin-RevId: 313396192
Change-Id: If18872476818bc9b2ad2340b22b4275140fbb000
2020-05-27 08:50:07 -07:00
A. Unique TensorFlower
ed01ecd92d Clarify docstring: At EOF, GFile.readline() returns "".
Along the way, fix a comment about the same topic.

PiperOrigin-RevId: 311537677
Change-Id: I8dbd4fbf12f617efc5fdff0eb615337dc9c2fa8d
2020-05-14 08:38:52 -07:00
Amit Patankar
949ce47d99 Release the GIL in file_io operations and reacquire it for error handling or Python specific operations.
PiperOrigin-RevId: 311027099
Change-Id: I5822df0b598f92efd14ea7ca4858b1a6181862d8
2020-05-11 17:25:51 -07:00
A. Unique TensorFlower
b0b883ff96 Improve tf.io.gfile.glob docs.
PiperOrigin-RevId: 308387182
Change-Id: I7091c03b8bd408f3e0c59e386e45d73a71f65a1b
2020-04-24 23:39:48 -07:00
TensorFlower Gardener
0277e80375 Merge pull request from perfinion:systemlibs-pybind
PiperOrigin-RevId: 305598649
Change-Id: I0a7845b01a7d0cb078d72e481ce640fc84977e9e
2020-04-08 18:48:06 -07:00
Akshay Modi
896efbf157 Remove use of multiprocessing in testFlush
The test was disabled in a variety of places due to multiprocessing being
flaky, so this seemed like an improvement.

PiperOrigin-RevId: 305360413
Change-Id: I5e383bebec23c8546d1b58cd7524e020d975591b
2020-04-07 16:13:04 -07:00
Jason Zaman
dc86bb5296 systemlibs: unbundle pybind11
If pybind11 is installed on the system its headers are already captured
by @local_config_python//:python_headers, so the system lib only needs
to depend on that.

When installed correctly, includes should be #include "pybind11/...",
the bundled pybind11 is based off the source repo which does not match
the install paths. Use bazels strip_include_prefix to align the bundled
headers correctly.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2020-04-08 03:38:38 +08:00
Mihai Maruseac
56f4edbb5a Fix GetMatchingPaths with special chars bug.
After 5659465166, `GetMatchingPaths` was converted to use RE2 instead of `fnmatch` as that allows non-local filesystems (e.g., GCS, Hadoop, S3) to also be used from Windows. However, this breaks compatibility between `tf.io.gfile.glob` and Python `glob` and that results in tests silently failing or examples being silently skipped during training.

The fix is two-pronged. First, to fix  only, we add regexp replacements for `(` and `)` in the pattern, escaping them before matching. After testing and seeing that this works, we then re-enable `fnmatch` on POSIX environments to reduce binary size, just like we did for mobile platforms.

Fixes  (everywhere) and  (on posix platforms).

Tested via `bazel run //tensorflow/python:file_io_test` after adding a test for the pattern in .

Will need to be cherry-picked onto `r2.2` branch.

PiperOrigin-RevId: 303009914
Change-Id: Ieab047f63e9ba6bb0ec0499e0fa864f6ca6090ff
2020-03-25 17:52:18 -07:00
TensorFlower Gardener
eacf534690 Merge pull request from rahul003:s3_skip_temp
PiperOrigin-RevId: 297455352
Change-Id: I41411282776981e9cf4e347b25d238557151f9e6
2020-02-26 14:49:31 -08:00
Rahul Huilgol
52f4a69a11 Revert "remove the try except block around hasAtomicMove"
This reverts commit 411f70eb0e.
2020-02-20 23:45:13 +00:00
Rahul Huilgol
cb5b00852c Remove s3 test in file_io 2020-02-20 23:44:04 +00:00
Rahul Huilgol
411f70eb0e remove the try except block around hasAtomicMove 2020-02-20 23:05:26 +00:00
Rahul Huilgol
e65e99c433 Not use temp files when writing to S3
Address feedback

Add test for the python method has_atomic_move

Removed old comment, and fixed indentation

Remove unncessary imports

Remove the test which checks for reference cycles when saving. Since the check for file system introduces a conditional op, it introduces a reference cycle, and this check does not apply anymore

Fighting lint

Fix lint errors

Use returned status of hasAtomicMove
2020-02-20 20:00:53 +00:00
Gunhan Gulsoy
029c732c9a Automated rollback of commit 2af37fc088
PiperOrigin-RevId: 294270240
Change-Id: Ica2bb12e39eb53ee9604f6a5e7c05177cde2025e
2020-02-10 11:54:00 -08:00
Gunhan Gulsoy
2af37fc088 Automated rollback of commit b818cbe0a5
PiperOrigin-RevId: 294115842
Change-Id: I97442754c3b8a0ac6b88d211981da494c7a3b796
2020-02-09 15:29:39 -08:00
Gunhan Gulsoy
b818cbe0a5 Change resource_loader to use bazel's python tools.
PiperOrigin-RevId: 294051693
Change-Id: I8a6c618be59e9f774e6b854ca9635cfac4a81cd0
2020-02-08 23:07:57 -08:00
Brian Atkinson
0357d7c0b4 Use resource_loader to access in-tree data.
PiperOrigin-RevId: 292242396
Change-Id: Id42aaf57d8de0b1605b36881f33a3b86216de1d0
2020-01-29 16:30:31 -08:00
Nick Felt
db26bd574f Add tf_record_iterator tests for semantics needed by TensorBoard
TensorBoard now uses tf_record_iterator and relies on new aspects of its behavior (preserving the read offset when encountering EOF or a data loss error, rather than closing the reader) to "poll" event files that get appended with new data during training, without having to reread the file from the beginning. To help prevent regressions that would break TensorBoard, this CL adds tests to verify that behavior.

PiperOrigin-RevId: 292066760
Change-Id: Ie15e055e30aa55398ff0dab3ae54f42e616d80a2
2020-01-28 20:19:48 -08:00
Amit Patankar
e9db50e8b4 Remove the last remnants of py_record_reader.i.
PiperOrigin-RevId: 292009749
Change-Id: Ic29fc0f3b7c7defaefafb00329e2e7d342de1ccb
2020-01-28 14:15:16 -08:00
A. Unique TensorFlower
4e8a6a0324 Release the GIL during FileExists to ensure other Python threads in the process can make progress.
PiperOrigin-RevId: 288734867
Change-Id: I2b2f9434ee65b2563951174ade643c60cebef330
2020-01-08 11:13:56 -08:00
Shanqing Cai
76e72928df Add tf_record_random_reader to support random-access reading.
Motivation:
- tfdbg2 needs to access tfrecord files (holding DebugEvent protos) at random offsets.
- However, tf_record.tf_record_iterator (implemented based on pybind11) doesn't support reading from random offsets.

Implementation description:
- Add new factory function in tf_record.py: tf_record_random_reader()
- The support is made available only for uncompressed tf_record file iterators.

PiperOrigin-RevId: 287832909
Change-Id: Icf08ef2d0091bdf191bc218a6e7eabd6e5c3f854
2020-01-02 07:33:57 -08:00
Sergei Lebedev
9d82907882 Converted file_io.i to pybind11
This is part of a larger effort to deprecate swig and eventually with
modularization break pywrap_tensorflow into smaller components.
Please refer to https://github.com/tensorflow/community/blob/master/rfcs/20190208-pybind11.md
for more information.

PiperOrigin-RevId: 286474536
Change-Id: Ic942a4480b1c1a19bdc3d6b65d3272221e47537b
2019-12-19 15:31:00 -08:00
Brian Atkinson
66c48046f1 Small adjustments on import spacing.
This is mostly the result of an internal cleanup and formatting pass.

PiperOrigin-RevId: 286318018
Change-Id: I8f9e2f7519070035da73f9f24d2fc90864abc51b
2019-12-18 20:32:12 -08:00
A. Unique TensorFlower
262213d0e4 Converted file_io.i to pybind11
This is part of a larger effort to deprecate swig and eventually with
modularization break pywrap_tensorflow into smaller components.
Please refer to https://github.com/tensorflow/community/blob/master/rfcs/20190208-pybind11.md
for more information.

PiperOrigin-RevId: 286302183
Change-Id: I4baf4a2628d46d7bdf3aa2916fb6f980a3c99abe
2019-12-18 17:57:45 -08:00
Sergei Lebedev
aeadabd45e Fixed a typo in file_io
PiperOrigin-RevId: 286209278
Change-Id: I66a292995dfefe2affc4dca098d87193342691f2
2019-12-18 09:46:30 -08:00
Sergei Lebedev
54f1de4fcf Converted py_record_writer.i and py_record_reader.i to pybind11
This is part of a larger effort to deprecate swig and eventually with
modularization break pywrap_tensorflow into smaller components.
Please refer to https://github.com/tensorflow/community/blob/master/rfcs/20190208-pybind11.md
for more information.

PiperOrigin-RevId: 286188001
Change-Id: Iebdc4335de88bc9e42267e68e28e0d7a9e840b9f
2019-12-18 07:36:29 -08:00
Sergei Lebedev
04941233e9 Converted file_io.i to pybind11
This is part of a larger effort to deprecate swig and eventually with
modularization break pywrap_tensorflow into smaller components.
Please refer to https://github.com/tensorflow/community/blob/master/rfcs/20190208-pybind11.md
for more information.

PiperOrigin-RevId: 286181704
Change-Id: I06e92ec7bc945c4efd69de85ef8b9e4de8007bf4
2019-12-18 06:49:37 -08:00
Taylor Robie
ca86f6cfe9 Update TFRecordWriter docstring.
PiperOrigin-RevId: 283866948
Change-Id: Id9dfa076ed3eb683f48e04dd5222848f90f889bc
2019-12-04 16:58:08 -08:00
Gunhan Gulsoy
3ba5046626 Move tensorflow::Status to tensorflow/core/platform
This is to make TF code structure better/easier to follow.

PiperOrigin-RevId: 282599457
Change-Id: I1fabbbaf7231e8f306d392633ff2a1adf5f639c8
2019-11-26 11:06:52 -08:00
Sergei Lebedev
b0895f89cd Added a missing %unignoreall to pywrap_tfe.i
Note that prior to this change lack of %unignoreall was compensated by
the ordering of includes.

PiperOrigin-RevId: 280669839
Change-Id: I5147c09bfa294ffcf4337077f8ef337efa1cd971
2019-11-15 09:09:29 -08:00
A. Unique TensorFlower
28d5603154 Update tf.io.gfile docstrings.
PiperOrigin-RevId: 272858669
2019-10-04 05:48:20 -07:00
A. Unique TensorFlower
b9d01a7f19 Clarify tf.io.gfile.walk docstring.
PiperOrigin-RevId: 272792871
2019-10-03 19:39:26 -07:00
Zachary Garrett
cf2a8e70c1 Update pydoc comment to point users to public API.
Otherwise tesnorflow.org documentation names a method that doesn't exist.

PiperOrigin-RevId: 267201451
2019-09-04 12:16:38 -07:00
Dero Gharibian
7ba3600c94 Updated ReaderInterface and subclasses to use tstring.
This is a part of a larger migration effort for tensorflow::tstring.
See: https://github.com/tensorflow/community/pull/91
PiperOrigin-RevId: 265822025
2019-08-27 20:01:38 -07:00
Akshay Modi
840f32a26f Split out multiprocessing specific test to a different file so that we can
disable the test on windows.

PiperOrigin-RevId: 257476078
2019-07-10 14:05:51 -07:00
Christian Sigg
3928354651 Make helper function global so it can be pickled.
Fixes Windows tests after CL/257051579.

PiperOrigin-RevId: 257232107
2019-07-09 11:37:26 -07:00
TensorFlower Gardener
1dabd52d9b Merge pull request from fo40225:fix_TFRecordWriter_Flush
PiperOrigin-RevId: 257051579
2019-07-08 18:21:08 -07:00