tensorflow: tf.io.gfile.listdir is inconsistent between GCS dir and local dir - adds trailing slashes

System information

  • TensorFlow version (use command below): v2.0.0-rc2-26-g64c3d38 2.0.0
  • Python version: 3.6

Describe the current behavior

When listing the directory items for a GCS dir, listdir returns names with trailing slashes. When listing the directory items for a local dir, listdir returns names without trailing slashes.

Describe the expected behavior

The behavior needs to be consistent.

Standalone code to reproduce the issue

tensorflow.io.gfile.listdir('gs://bucket/dir')
>>> ['eval/', 'train/']

tensorflow.io.gfile.listdir('..')
>>> ['eval', 'train']

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Can you please test if this also happens on 2.2-rc4?

I’ve tested this on 2.2.0. It’s still broken.

tensorflow.io.gfile.listdir('gs://gcp-public-data-landsat')

...
 'LC08/',
 'LE00/',
 'LE07/',
 'LM01/',
 'LM02/',
 'LM03/',
 'LM04/',
 'LM05/',
 'LO08/',
 'LT00/',
 'LT04/',
 'LT05/',
 'LT08/']
tensorflow.io.gfile.listdir('..')

['sys',
 'opt',
 'boot',
 'bin',
 'home',
 'usr',
...