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

feat(csv_reader): separate a method for csv_reader #906

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion dlt/common/configuration/specs/gcp_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class GcpCredentials(CredentialsConfiguration):

project_id: str = None

location: str = ( # DEPRECATED! and present only for backward compatibility. please set bigquery location in BigQuery configuration
location: (
str
) = ( # DEPRECATED! and present only for backward compatibility. please set bigquery location in BigQuery configuration
"US"
)

Expand Down
34 changes: 21 additions & 13 deletions dlt/common/storages/fsspec_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,14 @@ def fsspec_filesystem(
)


def fsspec_from_config(config: FilesystemConfiguration) -> Tuple[AbstractFileSystem, str]:
"""Instantiates an authenticated fsspec `FileSystem` from `config` argument.

Authenticates the following filesystems:
* s3
* az, abfs
* gcs, gs
def prepare_fsspec_args(config: FilesystemConfiguration) -> DictStrAny:
"""Prepare arguments for fsspec filesystem constructor.

Additional fsspec filesystem arguments and client arguments are gathered from the
FilesystemConfiguration object and passed to the `url_to_fs` factory.

All other filesystems are not authenticated

Returns: (fsspec filesystem, normalized url)
Args:
config (FilesystemConfiguration): The filesystem configuration.

Returns:
DictStrAny: The arguments for the fsspec filesystem constructor.
"""
proto = config.protocol
fs_kwargs: DictStrAny = {"use_listings_cache": False}
Expand All @@ -110,7 +103,22 @@ def fsspec_from_config(config: FilesystemConfiguration) -> Tuple[AbstractFileSys
fs_kwargs["client_kwargs"].update(credentials.pop("client_kwargs"))

fs_kwargs.update(credentials)
return fs_kwargs


def fsspec_from_config(config: FilesystemConfiguration) -> Tuple[AbstractFileSystem, str]:
"""Instantiates an authenticated fsspec `FileSystem` from `config` argument.

Authenticates following filesystems:
* s3
* az, abfs
* gcs, gs

All other filesystems are not authenticated

Returns: (fsspec filesystem, normalized url)
"""
fs_kwargs = prepare_fsspec_args(config)
try:
return url_to_fs(config.bucket_url, **fs_kwargs) # type: ignore
except ModuleNotFoundError as e:
Expand Down