Skip to main content

get_underlying_filesystem

Retrieves an fsspec filesystem instance for a given protocol or path, incorporating configured keyword arguments and additional user-provided arguments.

def get_underlying_filesystem(
protocol: typing.Optional[str] = None,
anonymous: bool = False,
path: typing.Optional[str] = None,
**kwargs: Any
) - > fsspec.AbstractFileSystem

Retrieves an fsspec filesystem instance based on the provided protocol or path. This function allows callers to interact with various storage backends (e.g., local, S3, GCS) in a unified way.

Parameters

NameTypeDescription
protocoltyping.Optional[str] = NoneThe filesystem protocol (e.g., 's3', 'file', 'gcs'). If None, the protocol is inferred from the 'path'.
anonymousbool = FalseA boolean indicating whether to access the filesystem anonymously. This is useful for public buckets or resources that do not require authentication.
pathtyping.Optional[str] = NoneA file path or URL from which to infer the protocol if 'protocol' is not provided. For example, 's3://my-bucket/file.txt' would infer 's3'.
**kwargsAnyAdditional keyword arguments to pass directly to the fsspec.filesystem constructor. These arguments can be used to configure specific filesystem options.

Returns

TypeDescription
fsspec.AbstractFileSystemAn fsspec.AbstractFileSystem instance configured for the specified protocol.