Skip to content

Commit 1b39aab

Browse files
authored
Avoid error if plugins .so module is not available (#1302)
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>
1 parent 22eddcb commit 1b39aab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tensorflow_io/core/python/ops/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import ctypes
1919
import sys
2020
import inspect
21+
import warnings
2122
import types
2223

2324
import tensorflow as tf
@@ -95,5 +96,8 @@ def __dir__(self):
9596
plugin_ops = _load_library("libtensorflow_io_plugins.so", "fs")
9697
except NotImplementedError as e:
9798
# Note: load libtensorflow_io.so imperatively in case of statically linking
98-
core_ops = _load_library("libtensorflow_io.so")
99-
plugin_ops = _load_library("libtensorflow_io.so", "fs")
99+
try:
100+
core_ops = _load_library("libtensorflow_io.so")
101+
plugin_ops = _load_library("libtensorflow_io.so", "fs")
102+
except NotImplementedError as e:
103+
warnings.warn("file system plugins are not loaded: {}".format(e))

0 commit comments

Comments
 (0)