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

Logging loading filesystems failures. #31219

Merged
merged 4 commits into from
May 21, 2024
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
45 changes: 40 additions & 5 deletions sdks/python/apache_beam/io/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# pytype: skip-file

import logging
import re
from typing import BinaryIO # pylint: disable=unused-import

Expand All @@ -27,6 +28,8 @@
from apache_beam.io.filesystem import FileSystem
from apache_beam.options.value_provider import RuntimeValueProvider

_LOGGER = logging.getLogger(__name__)

# All filesystem implements should be added here as
# best effort imports. We don't want to force loading
# a module if the user doesn't supply the correct
Expand All @@ -35,28 +38,60 @@
# pylint: disable=wrong-import-position, unused-import
try:
from apache_beam.io.hadoopfilesystem import HadoopFileSystem
except ImportError:
except ModuleNotFoundError:
Abacn marked this conversation as resolved.
Show resolved Hide resolved
RyuSA marked this conversation as resolved.
Show resolved Hide resolved
# optional file system packages are not installed.
pass
except ImportError as e:
_LOGGER.warning(
'Failed to import HadoopFileSystem; '
'loading of this filesystem will be skipped. '
'Error details: %s',
e)

try:
from apache_beam.io.localfilesystem import LocalFileSystem
except ImportError:
except ModuleNotFoundError:
pass
except ImportError as e:
RyuSA marked this conversation as resolved.
Show resolved Hide resolved
# optional file system packages are installed but failed to load.
_LOGGER.warning(
'Failed to import LocalFileSystem; '
'loading of this filesystem will be skipped. '
'Error details: %s',
e)

try:
from apache_beam.io.gcp.gcsfilesystem import GCSFileSystem
except ImportError:
except ModuleNotFoundError:
pass
except ImportError as e:
_LOGGER.warning(
'Failed to import GCSFileSystem; '
'loading of this filesystem will be skipped. '
'Error details: %s',
e)

try:
from apache_beam.io.aws.s3filesystem import S3FileSystem
except ImportError:
except ModuleNotFoundError:
pass
except ImportError as e:
_LOGGER.warning(
'Failed to import S3FileSystem; '
'loading of this filesystem will be skipped. '
'Error details: %s',
e)

try:
from apache_beam.io.azure.blobstoragefilesystem import BlobStorageFileSystem
except ImportError:
except ModuleNotFoundError:
pass
except ImportError as e:
_LOGGER.warning(
'Failed to import BlobStorageFileSystem; '
'loading of this filesystem will be skipped. '
'Error details: %s',
e)

# pylint: enable=wrong-import-position, unused-import

Expand Down
Loading