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

Avoid error if plugins .so module is not available #1302

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Changes from all 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
8 changes: 6 additions & 2 deletions tensorflow_io/core/python/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import ctypes
import sys
import inspect
import warnings
import types

import tensorflow as tf
Expand Down Expand Up @@ -95,5 +96,8 @@ def __dir__(self):
plugin_ops = _load_library("libtensorflow_io_plugins.so", "fs")
except NotImplementedError as e:
# Note: load libtensorflow_io.so imperatively in case of statically linking
core_ops = _load_library("libtensorflow_io.so")
plugin_ops = _load_library("libtensorflow_io.so", "fs")
try:
core_ops = _load_library("libtensorflow_io.so")
plugin_ops = _load_library("libtensorflow_io.so", "fs")
Copy link
Member

Choose a reason for hiding this comment

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

should we reload plugin_ops = _load_library("libtensorflow_io.so", "fs") only?

Copy link
Member Author

Choose a reason for hiding this comment

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

@burgerkingeater This part is specific to CentOS 7. In CentOS 7 we used static linking, that prompt us to combine libtensorflow_io.so and libtensorflow_io_plugins.so into one libtensorflow_io.so as static linking does not work with two .so. Notice the comment about:

Note: load libtensorflow_io.so imperatively in case of statically linking

When we have one libtensorflow_io.so file to load, due to tensorflow's limitations, it needs to be loaded with full symbols before file system symbols. So we use core_ops = _load_library("libtensorflow_io.so") before fs load.
This also means tensorflow-io on CentOS 7 can not have api backward-compatibility like other linux dist. This is a limitation that may only be resolved in CentOS 8 or higher.

except NotImplementedError as e:
warnings.warn("file system plugins are not loaded: {}".format(e))