tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
186.54k stars 74.33k forks source link

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

Open odashi opened 4 years ago

odashi commented 4 years ago

System information

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

ravikyram commented 4 years ago

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!

rmothukuru commented 4 years ago

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

Please find the Gist.

odashi commented 3 years ago

@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 commented 3 years ago

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

Venkat6871 commented 3 months ago

Hi,

Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.

The Tensorflow team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TensorFlow version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.

Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow space.

odashi commented 3 months ago

@Venkat6871 The issue is still happening as far as I checked the snippet posted on https://github.com/tensorflow/tensorflow/issues/45171#issuecomment-849382868

タイトルなし