Skip to content

Commit

Permalink
Relabel too-high tree ids in backend (#5484)
Browse files Browse the repository at this point in the history
* [WIP] relabel too-high tree ids in backend

* return skeleton with new trees
  • Loading branch information
fm3 authored May 12, 2021
1 parent ab6be10 commit f41f4ae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
### Fixed
- Fixed that the row selection in the user table wasn't properly preserved when filtering the table and (un)selecting rows. [#5486](https://github.com/scalableminds/webknossos/pull/5486)
- Fixed a bug where histograms generation failed for tiny datasets. [#5458](https://github.com/scalableminds/webknossos/pull/5458)
- Fixed a bug where NMLs with huge tree IDs uploaded via back-end produced broken annotations. [#5484](https://github.com/scalableminds/webknossos/pull/5484)
- Fixed a bug where the upload of multiple NMLs failed if some of them have an organization attribute and others don’t. [#5483](https://github.com/scalableminds/webknossos/pull/5483)

### Removed
Expand Down
2 changes: 1 addition & 1 deletion app/models/annotation/TracingStoreRpcClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object TracingStoreRpcClient {
class TracingStoreRpcClient(tracingStore: TracingStore, dataSet: DataSet, rpc: RPC)(implicit ec: ExecutionContext)
extends LazyLogging {

def baseInfo = s"Dataset: ${dataSet.name} Tracingstore: ${tracingStore.url}"
def baseInfo = s" Dataset: ${dataSet.name} Tracingstore: ${tracingStore.url}"

def getSkeletonTracing(tracingId: String, version: Option[Long]): Fox[SkeletonTracing] = {
logger.debug("Called to get SkeletonTracing." + baseInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ class SkeletonTracingController @Inject()(val tracingService: SkeletonTracingSer
AllowRemoteOrigin {
val tracings: List[Option[SkeletonTracing]] = request.body
val mergedTracing = tracingService.merge(tracings.flatten)
tracingService.save(mergedTracing, None, mergedTracing.version, toCache = !persist).map { newId =>
Ok(Json.toJson(newId))
}
val processedTracing = tracingService.remapTooLargeTreeIds(mergedTracing)
for {
newId <- tracingService.save(processedTracing, None, processedTracing.version, toCache = !persist)
} yield Ok(Json.toJson(newId))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ trait TracingService[T <: GeneratedMessage with Message[T]]

def merge(tracings: Seq[T]): T

def remapTooLargeTreeIds(tracing: T): T = tracing

def mergeVolumeData(tracingSelectors: Seq[TracingSelector],
tracings: Seq[T],
newId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ class SkeletonTracingService @Inject()(tracingDataStore: TracingDataStore,
)
}

// Can be removed again when https://github.com/scalableminds/webknossos/issues/5009 is fixed
override def remapTooLargeTreeIds(skeletonTracing: SkeletonTracing): SkeletonTracing =
if (skeletonTracing.trees.exists(_.treeId > 1048576)) {
val newTrees = for ((tree, index) <- skeletonTracing.trees.zipWithIndex) yield tree.withTreeId(index + 1)
skeletonTracing.withTrees(newTrees)
} else skeletonTracing

def mergeVolumeData(tracingSelectors: Seq[TracingSelector],
tracings: Seq[SkeletonTracing],
newId: String,
Expand Down

0 comments on commit f41f4ae

Please sign in to comment.