Skip to content

Commit 1562965

Browse files
authored
Support non-WKW layers for linking upon upload (#8773)
### URL of deployed dev instance (used for testing): - Support non-WKW layers for linking upon upload ### Steps to test: ``` import webknossos as wk import numpy as np ds = wk.Dataset("test", (1,1,1)) ds.write_layer("raw", wk.COLOR_CATEGORY, data=np.zeros((2,2))) ds.upload(layers_to_link=[wk.Dataset.open_remote("http://localhost:9000/datasets/l4_sample").get_layer("color")] ``` ------ (Please delete unneeded items, merge only when none are left open) - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`)
1 parent a5fd1b0 commit 1562965

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

unreleased_changes/8773.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed layer linking to support non-WKW layers.

webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/uploading/UploadService.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import com.google.inject.Inject
44
import com.scalableminds.util.io.PathUtils.ensureDirectoryBox
55
import com.scalableminds.util.io.{PathUtils, ZipIO}
66
import com.scalableminds.util.objectid.ObjectId
7-
import com.scalableminds.util.tools.{Fox, FoxImplicits, JsonHelper}
8-
import com.scalableminds.webknossos.datastore.dataformats.layers.{WKWDataLayer, WKWSegmentationLayer}
7+
import com.scalableminds.util.tools.Box.tryo
8+
import com.scalableminds.util.tools._
9+
import com.scalableminds.webknossos.datastore.dataformats.layers._
910
import com.scalableminds.webknossos.datastore.dataformats.wkw.WKWDataFormatHelper
1011
import com.scalableminds.webknossos.datastore.datareaders.n5.N5Header.FILENAME_ATTRIBUTES_JSON
1112
import com.scalableminds.webknossos.datastore.datareaders.n5.{N5Header, N5Metadata}
@@ -24,8 +25,6 @@ import com.scalableminds.webknossos.datastore.services.{
2425
}
2526
import com.scalableminds.webknossos.datastore.storage.DataStoreRedisStore
2627
import com.typesafe.scalalogging.LazyLogging
27-
import com.scalableminds.util.tools.Box.tryo
28-
import com.scalableminds.util.tools._
2928
import org.apache.commons.io.FileUtils
3029
import play.api.libs.json.{Json, OFormat, Reads}
3130

@@ -507,9 +506,17 @@ class UploadService @Inject()(dataSourceRepository: DataSourceRepository,
507506
layer: DataLayer <- usableDataSource.getDataLayer(layerIdentifier.layerName).toFox
508507
newName = layerIdentifier.newLayerName.getOrElse(layerIdentifier.layerName)
509508
layerRenamed: DataLayer <- layer match {
510-
case l: WKWSegmentationLayer => Fox.successful(l.copy(name = newName))
511-
case l: WKWDataLayer => Fox.successful(l.copy(name = newName))
512-
case _ => Fox.failure("Unknown layer type for link")
509+
case l: N5DataLayer => Fox.successful(l.copy(name = newName))
510+
case l: N5SegmentationLayer => Fox.successful(l.copy(name = newName))
511+
case l: PrecomputedDataLayer => Fox.successful(l.copy(name = newName))
512+
case l: PrecomputedSegmentationLayer => Fox.successful(l.copy(name = newName))
513+
case l: Zarr3DataLayer => Fox.successful(l.copy(name = newName))
514+
case l: Zarr3SegmentationLayer => Fox.successful(l.copy(name = newName))
515+
case l: ZarrDataLayer => Fox.successful(l.copy(name = newName))
516+
case l: ZarrSegmentationLayer => Fox.successful(l.copy(name = newName))
517+
case l: WKWDataLayer => Fox.successful(l.copy(name = newName))
518+
case l: WKWSegmentationLayer => Fox.successful(l.copy(name = newName))
519+
case _ => Fox.failure("Unknown layer type for link")
513520
}
514521
} yield layerRenamed
515522
}

0 commit comments

Comments
 (0)