Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFile does not create file when nothing is written. #45171

Open
odashi opened this issue Nov 25, 2020 · 4 comments
Open

GFile does not create file when nothing is written. #45171

odashi opened this issue Nov 25, 2020 · 4 comments
Assignees
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.9 Issues found in the TF 2.9 release (or RCs) type:bug Bug

Comments

@odashi
Copy link

odashi commented Nov 25, 2020

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS Catalina
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: NA
  • TensorFlow installed from (source or binary): binary (pip3)
  • TensorFlow version (use command below): v2.3.0-54-gfcc4b966f1 2.3.1
  • Python version: 3.8.2
  • Bazel version (if compiling from source): NA
  • GCC/Compiler version (if compiling from source): NA
  • CUDA/cuDNN version: NA
  • GPU model and memory: NA

Describe the current behavior

tf.io.gfile.GFile does nothing to the filesystem when it is closed without any write operations:

with tf.io.gfile.GFile('foo', 'wb') as fp:
  fp.write('test')  # 'foo' is created.

with tf.io.gfile.GFile('bar', 'wb'):
  pass  # 'bar' is not created.

Describe the expected behavior

The same behavior with builtin open: creates a file even if no write operation is invoked.

Standalone code to reproduce the issue
Already described above.

Other info / logs
NA

@odashi odashi added the type:bug Bug label Nov 25, 2020
@ravikyram ravikyram added comp:ops OPs related issues TF 2.3 Issues related to TF 2.3 labels Nov 25, 2020
@ravikyram
Copy link
Contributor

I have tried in colab with TF 2.3, nightly version( 2.5.0-dev20201125) and was able to reproduce the issue.Please, find the gist here. Thanks!

@ravikyram ravikyram assigned rmothukuru and unassigned ravikyram Nov 25, 2020
@rmothukuru
Copy link
Contributor

@odashi,
As per the Test Code, it works if we add fp2.write('') instead of pass.

Please find the Gist.

@rmothukuru rmothukuru added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 27, 2020
@odashi
Copy link
Author

odashi commented Nov 28, 2020

@rmothukuru
Thanks for pointing it out. Calling FGile.write() with an empty string seems to do something to the inner filesystem explicitly by a user. It is still not a desired solution to me -- matching the behavior with open.

@saikumarchalla
Copy link

saikumarchalla commented May 27, 2021

Still an issue in latest tf-nightly 2.10.0.dev2022072808.Please find the gist here.Thank you!

@sushreebarsa sushreebarsa added TF 2.9 Issues found in the TF 2.9 release (or RCs) and removed TF 2.3 Issues related to TF 2.3 labels Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.9 Issues found in the TF 2.9 release (or RCs) type:bug Bug
Projects
None yet
Development

No branches or pull requests

5 participants