Skip to content

Commit c6682fa

Browse files
Tobias314normanrz
andauthored
Fix _dump_mag_path for S3 paths (#1293)
* Fix _dump_mag_path for S3 paths * Remove trailing slashes when parsing/enriching s3 paths * Write changelog * lstrip --------- Co-authored-by: Norman Rzepka <[email protected]>
1 parent 90852e7 commit c6682fa

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1919
### Changed
2020

2121
### Fixed
22-
22+
For S3 mag paths, do not dump endpoint_url protocol ("https") in the mag path when writing to dataset_properties.json. Correctly parse S3 paths for remote mags when reading from dataset_properties.json.[#1293](https://github.com/scalableminds/webknossos-libs/pull/1293)
2323

2424
## [2.3.1](https://github.com/scalableminds/webknossos-libs/releases/tag/v2.3.1) - 2025-04-24
2525
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v2.3.0...v2.3.1)

webknossos/webknossos/dataset/layer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def _enrich_mag_path(path: str, dataset_path: Path) -> Path:
215215
elif upath.protocol == "s3":
216216
parsed_url = urlparse(str(upath))
217217
endpoint_url = f"https://{parsed_url.netloc}"
218-
bucket, key = parsed_url.path.split("/", maxsplit=1)
218+
bucket, key = parsed_url.path.lstrip("/").split("/", maxsplit=1)
219219

220220
return UPath(
221221
f"s3://{bucket}/{key}", client_kwargs={"endpoint_url": endpoint_url}
@@ -233,9 +233,7 @@ def _dump_mag_path(path: Path, dataset_path: Path) -> str:
233233
if path.is_relative_to(dataset_path):
234234
return str(path.relative_to(dataset_path))
235235
if isinstance(path, UPath) and path.protocol == "s3":
236-
return (
237-
f"s3://{path.storage_options['client_kwargs']['endpoint_url']}/{path.path}"
238-
)
236+
return f"s3://{urlparse(path.storage_options['client_kwargs']['endpoint_url']).netloc}/{path.path}"
239237
return str(path)
240238

241239

0 commit comments

Comments
 (0)