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

Switch to modular file system for hdfs #1309

Merged
merged 4 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tensorflow_io/core/plugins/file_system_plugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ limitations under the License.

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

#include "absl/strings/ascii.h"

void TF_InitPlugin(TF_FilesystemPluginInfo* info) {
const char* enable_legacy_env = getenv("TF_ENABLE_LEGACY_FILESYSTEM");
std::string enable_legacy =
enable_legacy_env ? absl::AsciiStrToLower(enable_legacy_env) : "";

info->plugin_memory_allocate = tensorflow::io::plugin_memory_allocate;
info->plugin_memory_free = tensorflow::io::plugin_memory_free;
info->num_schemes = 7;
Expand All @@ -25,8 +31,14 @@ void TF_InitPlugin(TF_FilesystemPluginInfo* info) {
tensorflow::io::az::ProvideFilesystemSupportFor(&info->ops[0], "az");
tensorflow::io::http::ProvideFilesystemSupportFor(&info->ops[1], "http");
tensorflow::io::s3::ProvideFilesystemSupportFor(&info->ops[2], "s3e");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfse");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfse");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "hare");
if (!(enable_legacy == "true" || enable_legacy == "1")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be more intuitive like this:
if (enable_legacy == "true" || enable_legacy == "1") {
/// legacy file system case
}
else {
/// non-legacy case
}

tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfs");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfs");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "har");
} else {
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[3], "hdfse");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[4], "viewfse");
tensorflow::io::hdfs::ProvideFilesystemSupportFor(&info->ops[5], "hare");
}
tensorflow::io::gs::ProvideFilesystemSupportFor(&info->ops[6], "gse");
}
4 changes: 2 additions & 2 deletions tensorflow_io/core/python/ops/version_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ==============================================================================
"""version_ops"""

package = "tensorflow>=2.4.0,<2.5.0"
version = "0.17.0"
package = "tf-nightly"
version = "0.18.0"
4 changes: 2 additions & 2 deletions tests/test_hdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def test_read_file():
print("ADDRESS: {}".format(address))

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

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