File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
sdks/python/apache_beam/io Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 2626import re
2727from typing import BinaryIO # pylint: disable=unused-import
2828
29- import hdfs
30-
3129from apache_beam .io import filesystemio
3230from apache_beam .io .filesystem import BeamIOError
3331from apache_beam .io .filesystem import CompressedFile
3735from apache_beam .options .pipeline_options import HadoopFileSystemOptions
3836from apache_beam .options .pipeline_options import PipelineOptions
3937
38+ try :
39+ import hdfs
40+ except ImportError :
41+ hdfs = None
42+
4043__all__ = ['HadoopFileSystem' ]
4144
4245_HDFS_PREFIX = 'hdfs:/'
@@ -108,6 +111,10 @@ def __init__(self, pipeline_options):
108111 See :class:`~apache_beam.options.pipeline_options.HadoopFileSystemOptions`.
109112 """
110113 super ().__init__ (pipeline_options )
114+ if hdfs is None :
115+ raise ImportError (
116+ 'Failed to import hdfs. You can ensure it is '
117+ 'installed by installing the hadoop beam extra' )
111118 logging .getLogger ('hdfs.client' ).setLevel (logging .WARN )
112119 if pipeline_options is None :
113120 raise ValueError ('pipeline_options is not set' )
You can’t perform that action at this time.
0 commit comments