Skip to content

Commit

Permalink
feat(csv_reader): separate a method for csv_reader
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaFaer committed Jan 23, 2024
1 parent d52558b commit 54da9fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
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

0 comments on commit 54da9fd

Please sign in to comment.