Skip to content

Commit 523e2fa

Browse files
authored
Fix add_symlink_layer properties lookup (#365)
1 parent b5f8f44 commit 523e2fa

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1818
### Changed
1919

2020
### Fixed
21+
- Fixed a bug where Dataset.add_symlink_layer(make_relative=True) failed to look up dataset properties. [#365](https://github.com/scalableminds/webknossos-cuber/pull/365)
2122

2223
## [0.8.4](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.4) - 2021-07-26
2324
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.3...v0.8.4)

wkcuber/api/dataset.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,18 @@ def add_symlink_layer(
419419
If make_relative is True, the symlink is made relative to the current dataset path.
420420
"""
421421
foreign_layer_path = Path(os.path.abspath(foreign_layer_path))
422-
if make_relative:
423-
foreign_layer_path = Path(os.path.relpath(foreign_layer_path, self.path))
424422
layer_name = foreign_layer_path.name
425423
if layer_name in self.layers.keys():
426424
raise IndexError(
427425
f"Cannot create symlink to {foreign_layer_path}. This dataset already has a layer called {layer_name}."
428426
)
429427

430-
os.symlink(foreign_layer_path, join(self.path, layer_name))
428+
foreign_layer_symlink_path = (
429+
Path(os.path.relpath(foreign_layer_path, self.path))
430+
if make_relative
431+
else foreign_layer_path
432+
)
433+
os.symlink(foreign_layer_symlink_path, join(self.path, layer_name))
431434

432435
# copy the properties of the layer into the properties of this dataset
433436
layer_properties = Dataset(foreign_layer_path.parent).properties.data_layers[

0 commit comments

Comments
 (0)