Skip to content

Commit df1b39e

Browse files
committed
Fix storage options for HTTP URLs (public B2 access)
1 parent 0f42422 commit df1b39e

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

gridfia/api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ def load_state(
974974
url = self.settings.cloud.get_state_url(state_upper)
975975

976976
# Merge config storage options with user-provided options
977-
config_options = self.settings.cloud.get_storage_options()
977+
# Pass URL to get correct options (HTTP vs S3)
978+
config_options = self.settings.cloud.get_storage_options(url=url)
978979
if storage_options:
979980
config_options.update(storage_options)
980981

@@ -1060,7 +1061,8 @@ def load_from_cloud(
10601061
)
10611062

10621063
# Merge config storage options with user-provided options
1063-
config_options = self.settings.cloud.get_storage_options()
1064+
# Pass URL to get correct options (HTTP vs S3)
1065+
config_options = self.settings.cloud.get_storage_options(url=url)
10641066
if storage_options:
10651067
config_options.update(storage_options)
10661068

gridfia/config.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,28 @@ def get_sample_url(self, sample_name: str) -> str:
110110
"""
111111
return f"{self.public_url}/{self.samples_prefix}/{sample_name}.zarr"
112112

113-
def get_storage_options(self) -> Dict[str, Any]:
113+
def get_storage_options(self, url: Optional[str] = None) -> Dict[str, Any]:
114114
"""Get fsspec storage options for this backend.
115115
116+
Args:
117+
url: Optional URL to determine protocol. If starts with http(s),
118+
returns empty options for public HTTP access.
119+
116120
Returns:
117121
Dictionary of options to pass to fsspec/zarr for cloud access
118122
"""
119123
options: Dict[str, Any] = {}
120124

125+
# For HTTP/HTTPS URLs (public bucket access), no special options needed
126+
# fsspec uses aiohttp backend which doesn't need S3 credentials
127+
if url and url.startswith(("http://", "https://")):
128+
return options
129+
121130
if self.backend == CloudStorageBackend.HTTP:
122-
# HTTP needs no special options for public access
131+
# HTTP backend explicitly set - no special options
123132
return options
124133

125-
# S3-compatible backends (B2, R2, S3)
134+
# S3-compatible backends (B2, R2, S3) - only for s3:// URLs
126135
if self.access_key and self.secret_key:
127136
options["key"] = self.access_key
128137
options["secret"] = self.secret_key

0 commit comments

Comments
 (0)