Skip to content

Commit

Permalink
Avoid error if plugins .so module is not available (tensorflow#1302)
Browse files Browse the repository at this point in the history
This PR raises a warning instead of an error in case
plugins .so module is not available, so that tensorflow-io
package can be at least partially used with python-only
functions.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
  • Loading branch information
yongtang authored and i-ony committed Mar 8, 2021
1 parent 65e85ba commit d9c6002
Showing 1 changed file with 6 additions and 2 deletions.
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")
except NotImplementedError as e:
warnings.warn("file system plugins are not loaded: {}".format(e))

0 comments on commit d9c6002

Please sign in to comment.