Skip to content

Commit 9b6ccb7

Browse files
authored
Switch to modular file system for hdfs (#1309)
* Switch to modular file system for hdfs This PR is part of the effort to switch to modular file system for hdfs. When TF_ENABLE_LEGACY_FILESYSTEM=1 is provided, old behavior will be preserved. Signed-off-by: Yong Tang <[email protected]> * Build against tf-nightly Signed-off-by: Yong Tang <[email protected]> * Update tests Signed-off-by: Yong Tang <[email protected]> * Adjust the if else logic, follow review comment Signed-off-by: Yong Tang <[email protected]>
1 parent f6cead0 commit 9b6ccb7

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

tensorflow_io/core/plugins/file_system_plugins.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ limitations under the License.
1515

1616
#include "tensorflow_io/core/plugins/file_system_plugins.h"
1717

18+
#include "absl/strings/ascii.h"
19+
1820
void TF_InitPlugin(TF_FilesystemPluginInfo* info) {
21+
const char* enable_legacy_env = getenv("TF_ENABLE_LEGACY_FILESYSTEM");
22+
std::string enable_legacy =
23+
enable_legacy_env ? absl::AsciiStrToLower(enable_legacy_env) : "";
24+
1925
info->plugin_memory_allocate = tensorflow::io::plugin_memory_allocate;
2026
info->plugin_memory_free = tensorflow::io::plugin_memory_free;
2127
info->num_schemes = 7;
@@ -25,8 +31,14 @@ void TF_InitPlugin(TF_FilesystemPluginInfo* info) {
2531
tensorflow::io::az::ProvideFilesystemSupportFor(&info->ops[0], "az");
2632
tensorflow::io::http::ProvideFilesystemSupportFor(&info->ops[1], "http");
2733
tensorflow::io::s3::ProvideFilesystemSupportFor(&info->ops[2], "s3e");
28-
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfse");
29-
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfse");
30-
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "hare");
34+
if (enable_legacy == "true" || enable_legacy == "1") {
35+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfse");
36+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfse");
37+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "hare");
38+
} else {
39+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfs");
40+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfs");
41+
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "har");
42+
}
3143
tensorflow::io::gs::ProvideFilesystemSupportFor(&info->ops[6], "gse");
3244
}

tensorflow_io/core/python/ops/version_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# ==============================================================================
1515
"""version_ops"""
1616

17-
package = "tensorflow>=2.4.0,<2.5.0"
18-
version = "0.17.0"
17+
package = "tf-nightly"
18+
version = "0.18.0"

tests/test_hdfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def test_read_file():
3535
print("ADDRESS: {}".format(address))
3636

3737
body = b"1234567"
38-
tf.io.write_file("hdfse://{}:9000/file.txt".format(address), body)
38+
tf.io.write_file("hdfs://{}:9000/file.txt".format(address), body)
3939

40-
content = tf.io.read_file("hdfse://{}:9000/file.txt".format(address))
40+
content = tf.io.read_file("hdfs://{}:9000/file.txt".format(address))
4141
print("CONTENT: {}".format(content))
4242
assert content == body

0 commit comments

Comments
 (0)