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

gdrive fsspec #738

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion dlt/common/storages/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FilesystemConfiguration(BaseConfiguration):
PROTOCOL_CREDENTIALS: ClassVar[Dict[str, Any]] = {
"gs": Union[GcpServiceAccountCredentials, GcpOAuthCredentials],
"gcs": Union[GcpServiceAccountCredentials, GcpOAuthCredentials],
"gdrive": GcpOAuthCredentials,
"gdrive": Union[GcpServiceAccountCredentials, GcpOAuthCredentials],
"s3": AwsCredentials,
"az": Union[AzureCredentialsWithoutDefaults, AzureCredentials],
"abfs": Union[AzureCredentialsWithoutDefaults, AzureCredentials],
Expand Down
8 changes: 6 additions & 2 deletions dlt/common/storages/fsspec_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FileItem(TypedDict, total=False):
"adl": lambda f: ensure_pendulum_datetime(f["LastModified"]),
"az": lambda f: ensure_pendulum_datetime(f["last_modified"]),
"gcs": lambda f: ensure_pendulum_datetime(f["updated"]),
"gdrive": lambda f: ensure_pendulum_datetime(f["modifiedTime"]),
"file": lambda f: ensure_pendulum_datetime(f["mtime"]),
"memory": lambda f: ensure_pendulum_datetime(f["created"]),
}
Expand Down Expand Up @@ -78,7 +79,7 @@ def fsspec_from_config(config: FilesystemConfiguration) -> Tuple[AbstractFileSys
fs_kwargs.update(cast(AwsCredentials, config.credentials).to_s3fs_credentials())
elif proto in ["az", "abfs", "adl", "azure"]:
fs_kwargs.update(cast(AzureCredentials, config.credentials).to_adlfs_credentials())
elif proto in ['gcs', 'gs']:
elif proto in ['gcs', 'gs', 'gdrive']:
assert isinstance(config.credentials, GcpCredentials)
# Default credentials are handled by gcsfs
if isinstance(config.credentials, CredentialsWithDefault) and config.credentials.has_default_credentials():
Expand Down Expand Up @@ -200,6 +201,9 @@ def glob_files(

bucket_path = bucket_url_parsed._replace(scheme='').geturl()
bucket_path = bucket_path[2:] if bucket_path.startswith("//") else bucket_path
bucket_path = bucket_path.split("?", 1)[0]
query = bucket_url_parsed.query

filter_url = posixpath.join(bucket_path, file_glob)

glob_result = fs_client.glob(filter_url, detail=True)
Expand All @@ -213,7 +217,7 @@ def glob_files(
if bucket_url_parsed.scheme == "file" and not file.startswith("/"):
file = "/" + file
file_name = posixpath.relpath(file, bucket_path)
file_url = bucket_url_parsed.scheme + "://" + file
file_url = bucket_url_parsed.scheme + "://" + file + ("?" + query if query else "")
yield FileItem(
file_name=file_name,
file_url=file_url,
Expand Down
Loading